refactor: let Aggregate chart manage legends
This commit is contained in:
parent
73fddf0623
commit
e0c1bde2ff
@ -1,4 +1,5 @@
|
|||||||
import BaseChart from './BaseChart';
|
import BaseChart from './BaseChart';
|
||||||
|
import { truncateString } from '../utils/draw-utils';
|
||||||
import { legendDot } from '../utils/draw';
|
import { legendDot } from '../utils/draw';
|
||||||
import { getExtraWidth } from '../utils/constants';
|
import { getExtraWidth } from '../utils/constants';
|
||||||
|
|
||||||
@ -75,13 +76,14 @@ export default class AggregationChart extends BaseChart {
|
|||||||
y += 20;
|
y += 20;
|
||||||
}
|
}
|
||||||
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 dot = legendDot(
|
let dot = legendDot(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
5,
|
5,
|
||||||
this.colors[i],
|
this.colors[i],
|
||||||
`${s.labels[i]}: ${d}`,
|
`${label}: ${d}`,
|
||||||
this.config.truncateLegends
|
false
|
||||||
);
|
);
|
||||||
this.legendArea.appendChild(dot);
|
this.legendArea.appendChild(dot);
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user