mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[agg_response/point_series] always assign series labels to points
Since forever, the vislib has been compensating for a behavior/bug in the agg_response module where "series" labels were not assigned to points if there wasn't a "series" aggregation or multiple y-axis. To compensate for this, the vislib was assigning the yAxisLabel to the series, which had the same effect, but now that the legend is rendered in it's own tick, followed by the visualization, and that behavior was being executed during the vislib render, the legend has been flashing an empty row for a while (this was worsened by the fact that vislib rendering did not trigger a digest cycle). These changes remove the workaround code from the vislib, and update the agg_response to always send the y-axis label as the series label when there is no series aggregation. Behavior with multiple-y-axis and multiple series aggs should be preserved.
This commit is contained in:
parent
4b08335fbb
commit
7460c0ac2d
4 changed files with 21 additions and 34 deletions
|
@ -27,6 +27,11 @@ export default function PointSeriesGetPoint() {
|
|||
if (series) {
|
||||
point.aggConfig = series.agg;
|
||||
point.series = series.agg.fieldFormatter()(unwrap(row[series.i]));
|
||||
} else if (y) {
|
||||
// If the data is not split up with a series aspect, then
|
||||
// each point's "series" becomes the y-agg that produced it
|
||||
point.aggConfig = y.col.aggConfig;
|
||||
point.series = y.col.title;
|
||||
}
|
||||
|
||||
if (yScale) {
|
||||
|
|
|
@ -23,9 +23,17 @@ export default function PointSeriesGetSeries(Private) {
|
|||
let point = partGetPoint(row, y, aspects.z);
|
||||
if (!point) return;
|
||||
|
||||
let prefix = point.series ? point.series + ': ' : '';
|
||||
let seriesId = prefix + y.agg.id;
|
||||
let seriesLabel = prefix + y.col.title;
|
||||
// use the point's y-axis as it's series by default,
|
||||
// but augment that with series aspect if it's actually
|
||||
// available
|
||||
let seriesId = y.agg.id;
|
||||
let seriesLabel = y.col.title;
|
||||
|
||||
if (aspects.series) {
|
||||
let prefix = point.series ? point.series + ': ' : '';
|
||||
seriesId = prefix + seriesId;
|
||||
seriesLabel = prefix + y.col.title;
|
||||
}
|
||||
|
||||
addToSiri(series, point, seriesId, seriesLabel);
|
||||
});
|
||||
|
|
|
@ -65,32 +65,8 @@ export default function DataFactory(Private) {
|
|||
}
|
||||
}
|
||||
|
||||
_updateData() {
|
||||
if (this.data.rows) {
|
||||
_.map(this.data.rows, this._updateDataSeriesLabel, this);
|
||||
} else if (this.data.columns) {
|
||||
_.map(this.data.columns, this._updateDataSeriesLabel, this);
|
||||
} else {
|
||||
this._updateDataSeriesLabel(this.data);
|
||||
}
|
||||
};
|
||||
|
||||
_updateDataSeriesLabel(eachData) {
|
||||
if (eachData.series) {
|
||||
eachData.series[0].label = this.get('yAxisLabel');
|
||||
}
|
||||
};
|
||||
|
||||
_getLabels(data) {
|
||||
if (this.type === 'series') {
|
||||
const noLabel = getLabels(data).length === 1 && getLabels(data)[0] === '';
|
||||
if (noLabel) {
|
||||
this._updateData();
|
||||
return [(this.get('yAxisLabel'))];
|
||||
}
|
||||
return getLabels(data);
|
||||
}
|
||||
return this.pieNames();
|
||||
return this.type === 'series' ? getLabels(data) : this.pieNames();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,8 @@ import _ from 'lodash';
|
|||
import VislibProvider from 'ui/vislib';
|
||||
import VisRenderbotProvider from 'ui/vis/renderbot';
|
||||
import VislibVisTypeBuildChartDataProvider from 'ui/vislib_vis_type/build_chart_data';
|
||||
module.exports = function VislibRenderbotFactory(Private) {
|
||||
module.exports = function VislibRenderbotFactory(Private, $injector) {
|
||||
const AngularPromise = $injector.get('Promise');
|
||||
let vislib = Private(VislibProvider);
|
||||
let Renderbot = Private(VisRenderbotProvider);
|
||||
let buildChartData = Private(VislibVisTypeBuildChartDataProvider);
|
||||
|
@ -46,11 +47,8 @@ module.exports = function VislibRenderbotFactory(Private) {
|
|||
VislibRenderbot.prototype.buildChartData = buildChartData;
|
||||
VislibRenderbot.prototype.render = function (esResponse) {
|
||||
this.chartData = this.buildChartData(esResponse);
|
||||
// to allow legend to render first (wait for angular digest cycle to complete)
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve(this.vislibVis.render(this.chartData, this.uiState));
|
||||
});
|
||||
return AngularPromise.delay(1).then(() => {
|
||||
this.vislibVis.render(this.chartData, this.uiState);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue