diff --git a/HISTORY.md b/HISTORY.md index 2733b91b..c2d7ab5e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -10,6 +10,7 @@ http://visjs.org ### Timeline +- Added axis orientation option `'none'`. - Improved function `fit()` to take into account the actual width of items. - Fixed #897: Timeline option `{snap: null}` did give a validation error. diff --git a/docs/timeline/index.html b/docs/timeline/index.html index 278d9f4c..eb1c058f 100644 --- a/docs/timeline/index.html +++ b/docs/timeline/index.html @@ -758,7 +758,7 @@ function (option, path) { orientation String or Object 'bottom' - Orientation of the timelines axis and items. When orientation is a string, the value is applied to both items and axis. Can be 'top', 'bottom' (default), or 'both'. + Orientation of the timelines axis and items. When orientation is a string, the value is applied to both items and axis. Can be 'top', 'bottom' (default), 'both', or 'none'. orientation.axis diff --git a/examples/timeline/styling/axisOrientation.html b/examples/timeline/styling/axisOrientation.html index 899a6bd2..cfabe312 100644 --- a/examples/timeline/styling/axisOrientation.html +++ b/examples/timeline/styling/axisOrientation.html @@ -25,6 +25,7 @@

diff --git a/lib/timeline/component/TimeAxis.js b/lib/timeline/component/TimeAxis.js index 2c81a7bb..750eb54a 100644 --- a/lib/timeline/component/TimeAxis.js +++ b/lib/timeline/component/TimeAxis.js @@ -129,21 +129,20 @@ TimeAxis.prototype.destroy = function() { * @return {boolean} Returns true if the component is resized */ TimeAxis.prototype.redraw = function () { - var options = this.options; var props = this.props; var foreground = this.dom.foreground; var background = this.dom.background; // determine the correct parent DOM element (depending on option orientation) - var parent = (options.orientation.axis == 'top') ? this.body.dom.top : this.body.dom.bottom; + var parent = (this.options.orientation.axis == 'top') ? this.body.dom.top : this.body.dom.bottom; var parentChanged = (foreground.parentNode !== parent); // calculate character width and height this._calculateCharSize(); // TODO: recalculate sizes only needed when parent is resized or options is changed - var showMinorLabels = this.options.showMinorLabels; - var showMajorLabels = this.options.showMajorLabels; + var showMinorLabels = this.options.showMinorLabels && this.options.orientation.axis !== 'none'; + var showMajorLabels = this.options.showMajorLabels && this.options.orientation.axis !== 'none'; // determine the width and height of the elemens for the axis props.minorLabelHeight = showMinorLabels ? props.minorCharHeight : 0; @@ -152,7 +151,7 @@ TimeAxis.prototype.redraw = function () { props.width = foreground.offsetWidth; props.minorLineHeight = this.body.domProps.root.height - props.majorLabelHeight - - (options.orientation.axis == 'top' ? this.body.domProps.bottom.height : this.body.domProps.top.height); + (this.options.orientation.axis == 'top' ? this.body.domProps.bottom.height : this.body.domProps.top.height); props.minorLineWidth = 1; // TODO: really calculate width props.majorLineHeight = props.minorLineHeight + props.majorLabelHeight; props.majorLineWidth = 1; // TODO: really calculate width diff --git a/test/timeline.html b/test/timeline.html index 0158b433..fa0bc6fa 100644 --- a/test/timeline.html +++ b/test/timeline.html @@ -49,6 +49,7 @@