From 9692d0df498184a940fe8345ed465261b63cfc9d Mon Sep 17 00:00:00 2001 From: Uli Fahrer Date: Sat, 17 Dec 2016 00:23:12 +0100 Subject: [PATCH] Fix error on click for graph2D when no data is provided (#2472) --- docs/graph2d/index.html | 2 +- lib/timeline/Graph2d.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/graph2d/index.html b/docs/graph2d/index.html index 8f07e20a..66a488f0 100644 --- a/docs/graph2d/index.html +++ b/docs/graph2d/index.html @@ -1162,7 +1162,7 @@ function (option, path) {
  • x (Number): relative horizontal position of the click event.
  • y (Number): relative vertical position of the click event.
  • time (Date): Date of the clicked event.
  • -
  • value (Number[]): The data value of the click event. The array contains one value when there is one data axis visible, and two values when there are two visible data axes.
  • +
  • value (Number[]): The data value of the click event. The array contains one value when there is one data axis visible, and two values when there are two visible data axes. It is empty when no data is provided.
  • what (String or null): name of the clicked thing: background, axis, dat-axis, custom-time, or current-time, legend.
  • event (Object): the original click event.
  • diff --git a/lib/timeline/Graph2d.js b/lib/timeline/Graph2d.js index cd350ec3..0e294592 100644 --- a/lib/timeline/Graph2d.js +++ b/lib/timeline/Graph2d.js @@ -299,10 +299,10 @@ Graph2d.prototype.getEventProperties = function (event) { var value = []; var yAxisLeft = this.linegraph.yAxisLeft; var yAxisRight = this.linegraph.yAxisRight; - if (!yAxisLeft.hidden) { + if (!yAxisLeft.hidden && this.itemsData.length > 0) { value.push(yAxisLeft.screenToValue(y)); } - if (!yAxisRight.hidden) { + if (!yAxisRight.hidden && this.itemsData.length > 0) { value.push(yAxisRight.screenToValue(y)); }