diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index 5d9963977de..3e02b1ec939 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -28,9 +28,10 @@ export function updateLegendValues(data: TimeSeries[], panel) { for (let i = 0; i < data.length; i++) { let series = data[i]; let yaxes = panel.yaxes; - let axis = yaxes[series.yaxis - 1]; + const seriesYAxis = series.yaxis || 1; + let axis = yaxes[seriesYAxis - 1]; let { tickDecimals, scaledDecimals } = getFlotTickDecimals(data, axis); - let formater = kbn.valueFormats[panel.yaxes[series.yaxis - 1].format]; + let formater = kbn.valueFormats[panel.yaxes[seriesYAxis - 1].format]; // decimal override if (_.isNumber(panel.decimals)) { diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 95f40fad02a..a4ddeec7777 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -13,7 +13,7 @@ import _ from 'lodash'; import moment from 'moment'; import kbn from 'app/core/utils/kbn'; import { tickStep } from 'app/core/utils/ticks'; -import { appEvents, coreModule } from 'app/core/core'; +import { appEvents, coreModule, updateLegendValues } from 'app/core/core'; import GraphTooltip from './graph_tooltip'; import { ThresholdManager } from './threshold_manager'; import { EventManager } from 'app/features/annotations/all'; @@ -62,6 +62,8 @@ function graphDirective(timeSrv, popoverSrv, contextSrv) { } annotations = ctrl.annotations || []; buildFlotPairs(data); + updateLegendValues(data, panel); + ctrl.events.emit('render-legend'); }); diff --git a/public/app/plugins/panel/graph/legend.ts b/public/app/plugins/panel/graph/legend.ts index 0ded048f8d6..5db0a122b31 100644 --- a/public/app/plugins/panel/graph/legend.ts +++ b/public/app/plugins/panel/graph/legend.ts @@ -2,7 +2,6 @@ import angular from 'angular'; import _ from 'lodash'; import $ from 'jquery'; import PerfectScrollbar from 'perfect-scrollbar'; -import { updateLegendValues } from 'app/core/core'; var module = angular.module('grafana.directives'); @@ -31,10 +30,6 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { ctrl.events.emit('legend-rendering-complete'); }); - function updateLegendDecimals() { - updateLegendValues(data, panel); - } - function getSeriesIndexForElement(el) { return el.parents('[data-series-index]').data('series-index'); } @@ -166,10 +161,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { // render first time for getting proper legend height if (!panel.legend.rightSide) { renderLegendElement(tableHeaderElem); - updateLegendDecimals(); elem.empty(); - } else { - updateLegendDecimals(); } renderLegendElement(tableHeaderElem);