From: Evert Timberg Date: Sun, 31 May 2015 14:24:53 +0000 (-0400) Subject: Add back line fill option. This is set on a per dataset basis, but there is an overri... X-Git-Tag: v2.0-alpha~2^2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e48c7f168ba48290ae99cfd69dc8ba27e1bd4384;p=thirdparty%2FChart.js.git Add back line fill option. This is set on a per dataset basis, but there is an override in the config. Demo this in the line sample. --- diff --git a/samples/line.html b/samples/line.html index 826a56866..7f96c553a 100644 --- a/samples/line.html +++ b/samples/line.html @@ -26,7 +26,8 @@ labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", - data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + fill: false }, { label: "My Second dataset", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a41e81f0e..a3b41c901 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -99,6 +99,8 @@ backgroundColor: defaultColor, borderWidth: 3, borderColor: defaultColor, + fill: true, // do we fill in the area between the line and the x axis + // Hover hitRadius: 6, hoverBorderWidth: 2, @@ -1271,10 +1273,11 @@ } } - if (this._children.length > 0) { + // If we had points and want to fill this line, do so. + if (this._children.length > 0 && vm.fill) { //Round off the line by going to the base of the chart, back to the start, then fill. - ctx.lineTo(this._children[this._children.length - 1].x, vm.scaleZero); - ctx.lineTo(this._children[0].x, vm.scaleZero); + ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero); + ctx.lineTo(this._children[0]._view.x, vm.scaleZero); ctx.fillStyle = vm.backgroundColor || Chart.defaults.global.defaultColor; ctx.closePath(); ctx.fill(); diff --git a/src/Chart.Line.js b/src/Chart.Line.js index ec2c766a6..fa54cb96d 100644 --- a/src/Chart.Line.js +++ b/src/Chart.Line.js @@ -170,6 +170,8 @@ backgroundColor: dataset.backgroundColor || this.options.elements.line.backgroundColor, borderWidth: dataset.borderWidth || this.options.elements.line.borderWidth, borderColor: dataset.borderColor || this.options.elements.line.borderColor, + fill: dataset.fill !== undefined ? dataset.fill : this.options.elements.line.fill, // use the value from the dataset if it was provided. else fall back to the default + // Scale scaleTop: yScale.top, scaleBottom: yScale.bottom,