From 846e2b32d4bdc3a75f4f433183087ba5192a93e8 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Sun, 2 Nov 2014 12:29:27 +0000 Subject: [PATCH] Catch case where title is undefined --- examples/graph2d/16_bothAxis_titles.html | 1 - lib/timeline/component/DataAxis.js | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/graph2d/16_bothAxis_titles.html b/examples/graph2d/16_bothAxis_titles.html index bc073c7a..dbc86e78 100644 --- a/examples/graph2d/16_bothAxis_titles.html +++ b/examples/graph2d/16_bothAxis_titles.html @@ -151,7 +151,6 @@ dataAxis: { showMinorLabels: false, title: { - left: false, right: { text: 'Right (right axis)' } diff --git a/lib/timeline/component/DataAxis.js b/lib/timeline/component/DataAxis.js index f80025b8..214040cb 100644 --- a/lib/timeline/component/DataAxis.js +++ b/lib/timeline/component/DataAxis.js @@ -368,7 +368,10 @@ DataAxis.prototype._redrawLabels = function () { } // Note that title is rotated, so we're using the height, not width! - var titleWidth = this.options.title[orientation].text === undefined ? 0 : this.props.titleCharHeight; + var titleWidth = 0; + if(this.options.title[orientation] !== undefined) { + titleWidth = this.props.titleCharHeight; + } var offset = this.options.icons == true ? Math.max(this.options.iconWidth, titleWidth) + this.options.labelOffsetX + 15 : titleWidth + this.options.labelOffsetX + 15; // this will resize the yAxis to accommodate the labels. @@ -470,7 +473,7 @@ DataAxis.prototype._redrawTitle = function (orientation) { DOMutil.prepareElements(this.DOMelements.title); // Check if the title is defined for this axes - if(this.options.title[orientation] == false || this.options.title[orientation].text === undefined) { + if(this.options.title[orientation] == undefined || this.options.title[orientation].text === undefined) { return; } var title = DOMutil.getDOMElement('div',this.DOMelements.title, this.dom.frame);