From 050bb4258ddfb2976a360eb2f89aac6a982d7780 Mon Sep 17 00:00:00 2001 From: Ludo Stellingwerff Date: Thu, 26 Nov 2015 10:32:00 +0100 Subject: [PATCH] Introduce "zero" shade orientation. --- lib/timeline/component/graph2d_types/line.js | 10 +++++++--- lib/timeline/optionsGraph2d.js | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/timeline/component/graph2d_types/line.js b/lib/timeline/component/graph2d_types/line.js index 7d70e8d3..7a866c3d 100644 --- a/lib/timeline/component/graph2d_types/line.js +++ b/lib/timeline/component/graph2d_types/line.js @@ -133,13 +133,17 @@ Line.prototype.draw = function (dataset, group, framework) { // append with points for fill and finalize the path if (group.options.shaded.enabled == true) { var fillPath = DOMutil.getSVGElement('path', framework.svgElements, framework.svg); - var dFill; + var zero = 0; if (group.options.shaded.orientation == 'top') { - dFill = 'M' + dataset[0].x + ',' + 0 + ' ' + d + 'L' + dataset[dataset.length - 1].x + ',' + 0; + zero = 0; + } + else if (group.options.shaded.orientation == 'bottom') { + zero = svgHeight; } else { - dFill = 'M' + dataset[0].x + ',' + svgHeight + ' ' + d + 'L' + dataset[dataset.length - 1].x + ',' + svgHeight; + zero = Math.min(Math.max(0,group.zeroPosition),svgHeight); } + var dFill = 'M' + dataset[0].x + ',' + zero + ' ' + d + 'L' + dataset[dataset.length - 1].x + ',' + zero; fillPath.setAttributeNS(null, 'class', group.className + ' vis-fill'); if(group.options.shaded.style !== undefined) { fillPath.setAttributeNS(null, 'style', group.options.shaded.style); diff --git a/lib/timeline/optionsGraph2d.js b/lib/timeline/optionsGraph2d.js index a2faf89d..e2f249c1 100644 --- a/lib/timeline/optionsGraph2d.js +++ b/lib/timeline/optionsGraph2d.js @@ -33,7 +33,7 @@ let allOptions = { graphHeight: {string, number}, shaded: { enabled: {boolean}, - orientation: {string:['bottom','top']}, // top, bottom + orientation: {string:['bottom','top','zero']}, // top, bottom, zero __type__: {boolean,object} }, style: {string:['line','bar','points']}, // line, bar @@ -171,7 +171,7 @@ let configureOptions = { stack:false, shaded: { enabled: false, - orientation: ['top','bottom'] // top, bottom + orientation: ['zero','top','bottom'] // zero, top, bottom }, style: ['line','bar','points'], // line, bar barChart: { @@ -266,4 +266,4 @@ let configureOptions = { } }; -export {allOptions, configureOptions}; \ No newline at end of file +export {allOptions, configureOptions};