From 7012eeb3e155a7c131bc806b8b4f761a7a5589f1 Mon Sep 17 00:00:00 2001 From: jos Date: Thu, 30 Apr 2015 14:07:56 +0200 Subject: [PATCH] Removed option clear --- docs/timeline.html | 12 ----------- lib/timeline/Core.js | 34 ++------------------------------ lib/timeline/component/Legend.js | 2 +- 3 files changed, 3 insertions(+), 45 deletions(-) diff --git a/docs/timeline.html b/docs/timeline.html index 6b92cac1..822f8b48 100644 --- a/docs/timeline.html +++ b/docs/timeline.html @@ -872,18 +872,6 @@ var options = { Returns ID of the newly created bar. - - clear([what]) - none - - Clear the Timeline. An object can be passed specifying which sections to clear: items, groups, - and/or options. By Default, items, groups and options are cleared, i.e. what = {items: true, groups: true, options: true}. Example usage: - -
timeline.clear();                // clear items, groups, and options
-timeline.clear({options: true}); // clear options only
-
- - destroy() diff --git a/lib/timeline/Core.js b/lib/timeline/Core.js index 11bed710..9dd08b9c 100644 --- a/lib/timeline/Core.js +++ b/lib/timeline/Core.js @@ -288,7 +288,8 @@ Core.prototype.isActive = function () { */ Core.prototype.destroy = function () { // unbind datasets - this.clear(); + this.setItems(null); + this.setGroups(null); // remove all event listeners this.off(); @@ -455,37 +456,6 @@ Core.prototype.getVisibleItems = function() { return this.itemSet && this.itemSet.getVisibleItems() || []; }; - - -/** - * Clear the Core. By Default, items, groups and options are cleared. - * Example usage: - * - * timeline.clear(); // clear items, groups, and options - * timeline.clear({options: true}); // clear options only - * - * @param {Object} [what] Optionally specify what to clear. By default: - * {items: true, groups: true, options: true} - */ -Core.prototype.clear = function(what) { - // clear items - if (!what || what.items) { - this.setItems(null); - } - - // clear groups - if (!what || what.groups) { - this.setGroups(null); - } - - // clear options of timeline and of each of the components - if (!what || what.options) { - this.components.forEach(component => component.setOptions(component.defaultOptions)); - - this.setOptions(this.defaultOptions); // this will also do a redraw - } -}; - /** * Set Core window such that it fits all items * @param {Object} [options] Available options: diff --git a/lib/timeline/component/Legend.js b/lib/timeline/component/Legend.js index 64be8b91..e34e9d95 100644 --- a/lib/timeline/component/Legend.js +++ b/lib/timeline/component/Legend.js @@ -39,7 +39,7 @@ Legend.prototype = new Component(); Legend.prototype.clear = function() { this.groups = {}; this.amountOfGroups = 0; -} +}; Legend.prototype.addGroup = function(label, graphOptions) {