Merge pull request #823 from MiguelMedeiros/fix-tooltip-inverted-chart
Fix tooltip mempool chart hover selection.
This commit is contained in:
		
						commit
						d9ec0c1a36
					
				| @ -162,24 +162,25 @@ export class MempoolGraphComponent implements OnInit, OnChanges { | ||||
|           type: 'line', | ||||
|         }, | ||||
|         formatter: (params: any) => { | ||||
|           const colorSpan = (item: any) => `<span class="indicator" style="background-color: ${this.chartColorsOrdered[item.seriesIndex]}"></span>
 | ||||
|           const colorSpan = (index: any) => `<span class="indicator" style="background-color: ${this.chartColorsOrdered[index]}"></span>
 | ||||
|             <span> | ||||
|               ${this.feeLevelsOrdered[item.seriesIndex]} | ||||
|               ${this.feeLevelsOrdered[index]} | ||||
|             </span>`;
 | ||||
|           const totals = (values: any) => { | ||||
|             let totalValueTemp = 0; | ||||
|             const totalValueArrayTemp = []; | ||||
|             const valuesInverted = [...values].reverse(); | ||||
|             const valuesInverted = this.inverted ? values : [...values].reverse(); | ||||
|             for (const item of valuesInverted) { | ||||
|               totalValueTemp += item.value; | ||||
|               totalValueArrayTemp.push(totalValueTemp); | ||||
|             } | ||||
|             return { | ||||
|               totalValue: totalValueTemp, | ||||
|               totalValueArray: totalValueArrayTemp.reverse() | ||||
|               totalValueArray: totalValueArrayTemp.reverse(), | ||||
|               values: this.inverted ? [...values].reverse() : values, | ||||
|             }; | ||||
|           }; | ||||
|           const { totalValue, totalValueArray } = totals(params); | ||||
|           const { totalValue, totalValueArray, values } = totals(params); | ||||
|           const title = `<div class="title">
 | ||||
|             ${params[0].axisValue} | ||||
|             <span class="total-value"> | ||||
| @ -197,7 +198,8 @@ export class MempoolGraphComponent implements OnInit, OnChanges { | ||||
|               progressPercentage = (item.value / totalValue) * 100; | ||||
|               progressPercentageSum = (totalValueArray[index] / totalValue) * 100; | ||||
|               let activeItemClass = ''; | ||||
|               if (this.hoverIndexSerie === index) { | ||||
|               const hoverActive = (this.inverted) ? Math.abs(item.seriesIndex - params.length + 1) : item.seriesIndex; | ||||
|               if (this.hoverIndexSerie === hoverActive) { | ||||
|                 progressPercentageText = `<div class="total-parcial-active">
 | ||||
|                   <span class="progress-percentage"> | ||||
|                     ${progressPercentage.toFixed(2)} | ||||
| @ -216,16 +218,16 @@ export class MempoolGraphComponent implements OnInit, OnChanges { | ||||
|               } | ||||
|               itemFormatted.push(`<tr class="item ${activeItemClass}">
 | ||||
|               <td class="indicator-container"> | ||||
|                 ${colorSpan(item)} | ||||
|                 ${colorSpan(item.seriesIndex)} | ||||
|               </td> | ||||
|               <td class="total-progress-sum"> | ||||
|                 <span> | ||||
|                   ${this.vbytesPipe.transform(item.value, 2, 'vB', 'MvB', false)} | ||||
|                   ${this.vbytesPipe.transform(values[item.seriesIndex].value, 2, 'vB', 'MvB', false)} | ||||
|                 </span> | ||||
|               </td> | ||||
|               <td class="total-progress-sum"> | ||||
|                 <span> | ||||
|                   ${this.vbytesPipe.transform(totalValueArray[index], 2, 'vB', 'MvB', false)} | ||||
|                   ${this.vbytesPipe.transform(totalValueArray[item.seriesIndex], 2, 'vB', 'MvB', false)} | ||||
|                 </span> | ||||
|               </td> | ||||
|               <td class="total-progress-sum-bar"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user