using field formatters for heatmap legend (#10529)

* using field formatters for heatmap legend

* fixing test
This commit is contained in:
Peter Pisljar 2017-02-24 21:06:22 +01:00 committed by GitHub
parent d38e3c260e
commit 7084d5573f
2 changed files with 10 additions and 6 deletions

View file

@ -44,13 +44,15 @@ export default function HeatmapChartFactory(Private) {
const percentageMode = cfg.get('percentageMode');
const colorsNumber = cfg.get('colorsNumber');
const colorsRange = cfg.get('colorsRange');
const zAxisConfig = this.getValueAxis().axisConfig;
const zAxisFormatter = zAxisConfig.get('labels.axisFormatter');
const zScale = this.getValueAxis().getScale();
const [min, max] = zScale.domain();
const labels = [];
if (cfg.get('setColorRange')) {
colorsRange.forEach(range => {
const from = range.from;
const to = range.to;
const from = isFinite(range.from) ? zAxisFormatter(range.from) : range.from;
const to = isFinite(range.to) ? zAxisFormatter(range.to) : range.to;
labels.push(`${from} - ${to}`);
});
} else {
@ -69,6 +71,8 @@ export default function HeatmapChartFactory(Private) {
val = Math.ceil(val);
nextVal = Math.ceil(nextVal);
}
if (isFinite(val)) val = zAxisFormatter(val);
if (isFinite(nextVal)) nextVal = zAxisFormatter(nextVal);
label = `${val} - ${nextVal}`;
}

View file

@ -74,10 +74,10 @@ bdd.describe('visualize app', function describeIndexTests() {
});
bdd.it('should show correct chart, take screenshot', function () {
const expectedChartValues = ['0 - 400', '0 - 400', '400 - 800', '1200 - 1600',
'1200 - 1600', '400 - 800', '0 - 400', '0 - 400', '0 - 400', '0 - 400', '400 - 800',
'1200 - 1600', '1200 - 1600', '400 - 800', '0 - 400', '0 - 400', '0 - 400', '0 - 400',
'400 - 800', '1200 - 1600', '1200 - 1600', '400 - 800', '0 - 400', '0 - 400' ];
const expectedChartValues = ['0 - 400', '0 - 400', '400 - 800', '1,200 - 1,600',
'1,200 - 1,600', '400 - 800', '0 - 400', '0 - 400', '0 - 400', '0 - 400', '400 - 800',
'1,200 - 1,600', '1,200 - 1,600', '400 - 800', '0 - 400', '0 - 400', '0 - 400', '0 - 400',
'400 - 800', '1,200 - 1,600', '1,200 - 1,600', '400 - 800', '0 - 400', '0 - 400' ];
// Most recent failure on Jenkins usually indicates the bar chart is still being drawn?
// return arguments[0].getAttribute(arguments[1]);","args":[{"ELEMENT":"592"},"fill"]}] arguments[0].getAttribute is not a function