From 4ac55e99af7bd5a91350967698387506c987bea0 Mon Sep 17 00:00:00 2001 From: Andrei Sedoi Date: Fri, 18 Sep 2015 14:53:12 +0000 Subject: [PATCH] add styles option back for data points It was implemented in commit 4e6c5a5 and accidentally deleted in commit f39c246. --- lib/DOMutil.js | 4 +-- lib/timeline/component/GraphGroup.js | 3 +- .../component/graph2d_types/points.js | 29 ++++++++++--------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/DOMutil.js b/lib/DOMutil.js index ebedeb21..722df764 100644 --- a/lib/DOMutil.js +++ b/lib/DOMutil.js @@ -149,8 +149,8 @@ exports.drawPoint = function(x, y, groupTemplate, JSONcontainer, svgContainer, l point.setAttributeNS(null, "height", groupTemplate.size); } - if (groupTemplate.style !== undefined) { - point.setAttributeNS(null, "style", groupTemplate.style); + if (groupTemplate.styles !== undefined) { + point.setAttributeNS(null, "style", groupTemplate.styles); } point.setAttributeNS(null, "class", groupTemplate.className + " vis-point"); //handle label diff --git a/lib/timeline/component/GraphGroup.js b/lib/timeline/component/GraphGroup.js index d9d53405..bcd7a77a 100644 --- a/lib/timeline/component/GraphGroup.js +++ b/lib/timeline/component/GraphGroup.js @@ -75,7 +75,7 @@ GraphGroup.prototype.setOptions = function(options) { onRender: options.drawPoints } } - + util.mergeOptions(this.options, options,'interpolation'); util.mergeOptions(this.options, options,'drawPoints'); util.mergeOptions(this.options, options,'shaded'); @@ -171,6 +171,7 @@ GraphGroup.prototype.drawIcon = function(x, y, JSONcontainer, SVGcontainer, icon if (this.options.drawPoints.enabled == true) { var groupTemplate = { style: this.options.drawPoints.style, + styles: this.options.drawPoints.styles, size:this.options.drawPoints.size, className: this.className }; diff --git a/lib/timeline/component/graph2d_types/points.js b/lib/timeline/component/graph2d_types/points.js index f54df328..9e497f60 100644 --- a/lib/timeline/component/graph2d_types/points.js +++ b/lib/timeline/component/graph2d_types/points.js @@ -35,8 +35,8 @@ Points.draw = function (dataset, group, framework, offset) { for (var i = 0; i < dataset.length; i++) { if (!callback) { - // draw the point the simple way. - DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, getGroupTemplate(), framework.svgElements, framework.svg, dataset[i].label); + // draw the point the simple way. + DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, getGroupTemplate(), framework.svgElements, framework.svg, dataset[i].label); } else { var callbackResult = callback(dataset[i], group, framework); // result might be true, false or an object @@ -47,26 +47,27 @@ Points.draw = function (dataset, group, framework, offset) { } function getGroupTemplate(callbackResult) { - callbackResult = (typeof callbackResult === 'undefined') ? {} : callbackResult; - return { - style: callbackResult.style || group.options.drawPoints.style, - size: callbackResult.size || group.options.drawPoints.size, - className: callbackResult.className || group.className - }; + callbackResult = (typeof callbackResult === 'undefined') ? {} : callbackResult; + return { + style: callbackResult.style || group.options.drawPoints.style, + styles: callbackResult.styles || group.options.drawPoints.styles, + size: callbackResult.size || group.options.drawPoints.size, + className: callbackResult.className || group.className + }; } - + function getCallback() { - var callback = undefined; + var callback = undefined; // check for the graph2d onRender if (framework.options.drawPoints.onRender && typeof framework.options.drawPoints.onRender == 'function') { - callback = framework.options.drawPoints.onRender; + callback = framework.options.drawPoints.onRender; } - + // override it with the group onRender if defined if (group.group.options && group.group.options.drawPoints && group.group.options.drawPoints.onRender && typeof group.group.options.drawPoints.onRender == 'function') { - callback = group.group.options.drawPoints.onRender; + callback = group.group.options.drawPoints.onRender; } - + return callback; } };