]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Added a scaleBackgroundColors configuration option for Radial charts, to add a backgr...
authorRahul Vaidya <rahul@rvaidya.com>
Thu, 16 Apr 2015 08:23:09 +0000 (01:23 -0700)
committerRahul Vaidya <rahul@rvaidya.com>
Thu, 16 Apr 2015 16:22:31 +0000 (09:22 -0700)
src/Chart.Core.js
src/Chart.Radar.js

index a86fe4536763a8827f4924714c76da10e4d9feee..e51d4d4b2e6b1234d12db3fe41e140607cb9fd8d 100755 (executable)
                                                        ctx.lineTo(outerPosition.x, outerPosition.y);
                                                        ctx.stroke();
                                                        ctx.closePath();
+
+                                                       if (this.backgroundColors) {
+                                                               var previousOuterPosition = this.getPointPosition(i === 0 ? this.valuesCount - 1 : i - 1, this.calculateCenterOffset(this.max));
+                                                               var nextOuterPosition = this.getPointPosition(i === this.valuesCount - 1 ? 0 : i + 1, this.calculateCenterOffset(this.max));
+
+                                                               var previousOuterHalfway = { x: (previousOuterPosition.x + outerPosition.x) / 2, y: (previousOuterPosition.y + outerPosition.y) / 2 };
+                                                               var nextOuterHalfway = { x: (outerPosition.x + nextOuterPosition.x) / 2, y: (outerPosition.y + nextOuterPosition.y) / 2 };
+
+                                                               ctx.beginPath();
+                                                               ctx.moveTo(this.xCenter, this.yCenter);
+                                                               ctx.lineTo(previousOuterHalfway.x, previousOuterHalfway.y);
+                                                               ctx.lineTo(outerPosition.x, outerPosition.y);
+                                                               ctx.lineTo(nextOuterHalfway.x, nextOuterHalfway.y);
+                                                               ctx.fillStyle = this.backgroundColors[i];
+                                                               ctx.fill();
+                                                               ctx.closePath();
+                                                       }
                                                }
                                                // Extra 3px out for some label spacing
                                                var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5);
index 134fd2d021866ccf25cdc4902b3d1f8de59b36ba..f48dc4bdb8da21e09e6a5a5c552618e7ad1a043b 100644 (file)
                                showLabels: this.options.scaleShowLabels,
                                showLabelBackdrop: this.options.scaleShowLabelBackdrop,
                                backdropColor: this.options.scaleBackdropColor,
+                               backgroundColors: this.options.scaleBackgroundColors,
                                backdropPaddingY : this.options.scaleBackdropPaddingY,
                                backdropPaddingX: this.options.scaleBackdropPaddingX,
                                lineWidth: (this.options.scaleShowLine) ? this.options.scaleLineWidth : 0,