Merge pull request #309 from SaiFi0102/AggregateChart-Formatter

fix(AggregationChart): Formatter not being applied
This commit is contained in:
Shivam Mishra 2020-10-09 17:13:57 +05:30 committed by GitHub
commit f644e19a5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ export default class AggregationChart extends BaseChart {
configure(args) { configure(args) {
super.configure(args); super.configure(args);
this.config.formatTooltipY = args.tooltipOptions.formatTooltipY;
this.config.maxSlices = args.maxSlices || 20; this.config.maxSlices = args.maxSlices || 20;
this.config.maxLegendPoints = args.maxLegendPoints || 20; this.config.maxLegendPoints = args.maxLegendPoints || 20;
} }
@ -77,12 +78,13 @@ export default class AggregationChart extends BaseChart {
} }
let x = barWidth * count + 5; let x = barWidth * count + 5;
let label = this.config.truncateLegends ? truncateString(s.labels[i], barWidth/10) : s.labels[i]; let label = this.config.truncateLegends ? truncateString(s.labels[i], barWidth/10) : s.labels[i];
let formatted = this.config.formatTooltipY ? this.config.formatTooltipY(d) : d;
let dot = legendDot( let dot = legendDot(
x, x,
y, y,
5, 5,
this.colors[i], this.colors[i],
`${label}: ${d}`, `${label}: ${formatted}`,
false false
); );
this.legendArea.appendChild(dot); this.legendArea.appendChild(dot);