Browse Source

Introduce "zero" shade orientation.

newShading
Ludo Stellingwerff 8 years ago
parent
commit
050bb4258d
2 changed files with 10 additions and 6 deletions
  1. +7
    -3
      lib/timeline/component/graph2d_types/line.js
  2. +3
    -3
      lib/timeline/optionsGraph2d.js

+ 7
- 3
lib/timeline/component/graph2d_types/line.js View File

@ -133,13 +133,17 @@ Line.prototype.draw = function (dataset, group, framework) {
// append with points for fill and finalize the path // append with points for fill and finalize the path
if (group.options.shaded.enabled == true) { if (group.options.shaded.enabled == true) {
var fillPath = DOMutil.getSVGElement('path', framework.svgElements, framework.svg); var fillPath = DOMutil.getSVGElement('path', framework.svgElements, framework.svg);
var dFill;
var zero = 0;
if (group.options.shaded.orientation == 'top') { 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 { 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'); fillPath.setAttributeNS(null, 'class', group.className + ' vis-fill');
if(group.options.shaded.style !== undefined) { if(group.options.shaded.style !== undefined) {
fillPath.setAttributeNS(null, 'style', group.options.shaded.style); fillPath.setAttributeNS(null, 'style', group.options.shaded.style);

+ 3
- 3
lib/timeline/optionsGraph2d.js View File

@ -33,7 +33,7 @@ let allOptions = {
graphHeight: {string, number}, graphHeight: {string, number},
shaded: { shaded: {
enabled: {boolean}, enabled: {boolean},
orientation: {string:['bottom','top']}, // top, bottom
orientation: {string:['bottom','top','zero']}, // top, bottom, zero
__type__: {boolean,object} __type__: {boolean,object}
}, },
style: {string:['line','bar','points']}, // line, bar style: {string:['line','bar','points']}, // line, bar
@ -171,7 +171,7 @@ let configureOptions = {
stack:false, stack:false,
shaded: { shaded: {
enabled: false, enabled: false,
orientation: ['top','bottom'] // top, bottom
orientation: ['zero','top','bottom'] // zero, top, bottom
}, },
style: ['line','bar','points'], // line, bar style: ['line','bar','points'], // line, bar
barChart: { barChart: {
@ -266,4 +266,4 @@ let configureOptions = {
} }
}; };
export {allOptions, configureOptions};
export {allOptions, configureOptions};

Loading…
Cancel
Save