mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
adding heatmap vislib type
This commit is contained in:
parent
8815e1c1ce
commit
d3b3065603
6 changed files with 74 additions and 7 deletions
|
@ -130,8 +130,8 @@ export default function AxisScaleFactory(Private) {
|
|||
const max = this.axisConfig.get('scale.max') || this.getYMax();
|
||||
const domain = [min, max];
|
||||
if (this.axisConfig.isUserDefined()) return this.validateUserExtents(domain);
|
||||
if (this.axisConfig.isYExtents()) return domain;
|
||||
if (this.axisConfig.isLogScale()) return this.logDomain(min, max);
|
||||
if (this.axisConfig.isYExtents()) return domain;
|
||||
return [Math.min(0, min), Math.max(0, max)];
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ export default function TypeFactory(Private) {
|
|||
line: pointSeries.line,
|
||||
pie: Private(VislibLibTypesPieProvider),
|
||||
area: pointSeries.area,
|
||||
point_series: pointSeries.line
|
||||
point_series: pointSeries.line,
|
||||
heatmap: pointSeries.heatmap,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,39 @@
|
|||
import _ from 'lodash';
|
||||
import errors from 'ui/errors';
|
||||
import heatmapColorFunc from 'ui/vislib/components/color/heatmap_color';
|
||||
|
||||
export default function ColumnHandler(Private) {
|
||||
|
||||
const getHeatmapLabels = (cfg) => {
|
||||
const colorsNumber = cfg.colorsNumber;
|
||||
const labels = [];
|
||||
for (let i = 0; i < colorsNumber; i++) {
|
||||
let label;
|
||||
const val = Math.ceil(i * (100 / colorsNumber));
|
||||
if (cfg.setColorRange) {
|
||||
const greaterThan = cfg.colorsRange[i].value;
|
||||
label = `> ${greaterThan}`;
|
||||
} else {
|
||||
const nextVal = Math.ceil((i + 1) * (100 / colorsNumber));
|
||||
label = `${val}% - ${nextVal}%`;
|
||||
}
|
||||
labels.push(label);
|
||||
}
|
||||
return labels;
|
||||
};
|
||||
|
||||
const getHeatmapColors = (cfg) => {
|
||||
const colorsNumber = cfg.colorsNumber;
|
||||
const labels = getHeatmapLabels(cfg);
|
||||
const colors = {};
|
||||
for (let i in labels) {
|
||||
if (labels[i]) {
|
||||
colors[labels[i]] = heatmapColorFunc(Math.ceil(i * 10 / colorsNumber), cfg.colorSchema);
|
||||
}
|
||||
}
|
||||
return colors;
|
||||
};
|
||||
|
||||
const createSeries = (cfg, series) => {
|
||||
const stacked = ['stacked', 'percentage', 'wiggle', 'silhouette'].includes(cfg.mode);
|
||||
let interpolate = cfg.interpolate;
|
||||
|
@ -104,6 +136,8 @@ export default function ColumnHandler(Private) {
|
|||
config.charts = createCharts(cfg, data.data);
|
||||
}
|
||||
|
||||
if (typeof config.enableHover === 'undefined') config.enableHover = true;
|
||||
|
||||
return config;
|
||||
};
|
||||
}
|
||||
|
@ -140,6 +174,28 @@ export default function ColumnHandler(Private) {
|
|||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}),
|
||||
|
||||
heatmap: (cfg, data) => {
|
||||
const defaults = create()(cfg, data);
|
||||
defaults.valueAxes[0].show = false;
|
||||
defaults.categoryAxes.push({
|
||||
id: 'CategoryAxis-2',
|
||||
type: 'category',
|
||||
position: 'left',
|
||||
values: data.getLabels(),
|
||||
labels: {
|
||||
axisFormatter: val => val
|
||||
},
|
||||
title: {
|
||||
text: data.get('yAxisLabel')
|
||||
}
|
||||
});
|
||||
defaults.legend = {
|
||||
labels: getHeatmapLabels(cfg),
|
||||
colors: getHeatmapColors(cfg)
|
||||
};
|
||||
return defaults;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,6 +33,11 @@ export default function PointSeriesFactory(Private) {
|
|||
this.chartEl = chartEl;
|
||||
this.chartConfig = this.findChartConfig();
|
||||
this.handler.pointSeries = this;
|
||||
|
||||
const seriesLimit = 25;
|
||||
if (this.chartConfig.series.length > seriesLimit) {
|
||||
throw new errors.VislibError('There are too many series defined.');
|
||||
}
|
||||
}
|
||||
|
||||
findChartConfig() {
|
||||
|
|
|
@ -80,10 +80,13 @@ export default function PointSeriesProvider(Private) {
|
|||
|
||||
addCircleEvents(element) {
|
||||
const events = this.events;
|
||||
const hover = events.addHoverEvent();
|
||||
const mouseout = events.addMouseoutEvent();
|
||||
if (this.handler.visConfig.get('enableHover')) {
|
||||
const hover = events.addHoverEvent();
|
||||
const mouseout = events.addMouseoutEvent();
|
||||
element.call(hover).call(mouseout);
|
||||
}
|
||||
const click = events.addClickEvent();
|
||||
return element.call(hover).call(mouseout).call(click);
|
||||
return element.call(click);
|
||||
}
|
||||
|
||||
checkIfEnoughData() {
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import VislibVisualizationsColumnChartProvider from './column_chart';
|
||||
import VislibVisualizationsLineChartProvider from './line_chart';
|
||||
import VislibVisualizationsAreaChartProvider from './area_chart';
|
||||
import VislibVisualizationsHeatmapChartProvider from './heatmap_chart';
|
||||
|
||||
export default function SeriesTypeFactory(Private) {
|
||||
|
||||
return {
|
||||
histogram: Private(VislibVisualizationsColumnChartProvider),
|
||||
line: Private(VislibVisualizationsLineChartProvider),
|
||||
area: Private(VislibVisualizationsAreaChartProvider)
|
||||
area: Private(VislibVisualizationsAreaChartProvider),
|
||||
heatmap: Private(VislibVisualizationsHeatmapChartProvider)
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue