Toggling spy panel no longer throws an error (#8877)

Complete existence check of highlight-handler, before using it
This commit is contained in:
Thomas Neirynck 2016-10-31 16:45:52 -04:00 committed by GitHub
parent a5d2b4d973
commit 5a8aaa29e8
3 changed files with 7 additions and 10 deletions

View file

@ -1,7 +1,5 @@
import _ from 'lodash';
import template from 'ui/filter_bar/filter_bar.html';
import moment from 'moment';
import angular from 'angular';
import 'ui/directives/json_input';
import filterAppliedAndUnwrap from 'ui/filter_bar/lib/filter_applied_and_unwrap';
import FilterBarLibMapAndFlattenFiltersProvider from 'ui/filter_bar/lib/map_and_flatten_filters';

View file

@ -20,7 +20,6 @@ export default function HandlerBaseClass(Private) {
*/
class Handler {
constructor(vis, opts) {
this.data = opts.data || new Data(vis.data, vis._attr, vis.uiState);
this.vis = vis;
this.el = vis.el;
@ -78,7 +77,6 @@ export default function HandlerBaseClass(Private) {
*/
this.disable = this.chartEventProxyToggle('off');
}
/**
* Validates whether data is actually present in the data object
* used to render the Vis. Throws a no results error if data is not

View file

@ -1,8 +1,5 @@
import _ from 'lodash';
import html from 'ui/visualize/visualize_legend.html';
import $ from 'jquery';
import d3 from 'd3';
import findByParam from 'ui/utils/find_by_param';
import VislibLibDataProvider from 'ui/vislib/lib/data';
import VislibComponentsColorColorProvider from 'ui/vislib/components/color/color';
import FilterBarFilterBarClickHandlerProvider from 'ui/filter_bar/filter_bar_click_handler';
@ -18,7 +15,7 @@ uiModules.get('kibana')
return {
restrict: 'E',
template: html,
link: function ($scope, $elem) {
link: function ($scope) {
let $state = getAppState();
let clickHandler = filterBarClickHandler($state);
$scope.open = $scope.uiState.get('vis.legendOpen', true);
@ -32,7 +29,11 @@ uiModules.get('kibana')
$scope.highlight = function (event) {
let el = event.currentTarget;
let handler = $scope.renderbot.vislibVis.handler;
if (!handler) return;
//there is no guarantee that a Chart will set the highlight-function on its handler
if (!handler || typeof handler.highlight !== 'function') {
return;
}
handler.highlight.call(el, handler.el);
};
@ -110,7 +111,7 @@ uiModules.get('kibana')
data = data.columns || data.rows || [data];
if (type === 'pie') return Data.prototype.pieNames(data);
return getSeriesLabels(data);
};
}
function getSeriesLabels(data) {
let values = data.map(function (chart) {