]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Move linearRadial default config to be a property of the scale. 1207/head
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 13 Jun 2015 18:16:01 +0000 (14:16 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 13 Jun 2015 18:16:01 +0000 (14:16 -0400)
src/charts/chart.polarArea.js
src/charts/chart.radar.js
src/charts/chart.scatter.js
src/core/core.js
src/scales/scale.radialLinear.js

index 4131e6bc01c0b2924ccc9b5c8a3ed24ef4348987..b1f6a0f8fa0cfc120d775ad6922f8fedf386ea2f 100644 (file)
 
                scale: {
                        type: "radialLinear",
-                       display: true,
-
-                       //Boolean - Whether to animate scaling the chart from the centre
-                       animate: false,
-
-                       lineArc: true,
-
-                       // grid line settings
-                       gridLines: {
-                               show: true,
-                               color: "rgba(0, 0, 0, 0.05)",
-                               lineWidth: 1,
-                       },
-
-                       // scale numbers
-                       beginAtZero: true,
-
-                       // label settings
-                       labels: {
-                               show: true,
-                               template: "<%=value.toLocaleString()%>",
-                               fontSize: 12,
-                               fontStyle: "normal",
-                               fontColor: "#666",
-                               fontFamily: "Helvetica Neue",
-
-                               //Boolean - Show a backdrop to the scale label
-                               showLabelBackdrop: true,
-
-                               //String - The colour of the label backdrop
-                               backdropColor: "rgba(255,255,255,0.75)",
-
-                               //Number - The backdrop padding above & below the label in pixels
-                               backdropPaddingY: 2,
-
-                               //Number - The backdrop padding to the side of the label in pixels
-                               backdropPaddingX: 2,
-                       }
+                       lineArc: true, // so that lines are circular
                },
 
                //Boolean - Whether to animate the rotation of the chart
index 3d911070f94d0d94ece152e0535604fffb3f9064..bff30df9005c5ca900ffcc5747cc484502e636d3 100644 (file)
 
                        scale: {
                                type: "radialLinear",
-                               display: true,
-
-                               //Boolean - Whether to animate scaling the chart from the centre
-                               animate: false,
-
-                               lineArc: false,
-
-                               // grid line settings
-                               gridLines: {
-                                       show: true,
-                                       color: "rgba(0, 0, 0, 0.05)",
-                                       lineWidth: 1,
-                               },
-
-                               angleLines: {
-                                       show: true,
-                                       color: "rgba(0,0,0,.1)",
-                                       lineWidth: 1
-                               },
-
-                               // scale numbers
-                               beginAtZero: true,
-
-                               // label settings
-                               labels: {
-                                       show: true,
-                                       template: "<%=value.toLocaleString()%>",
-                                       fontSize: 12,
-                                       fontStyle: "normal",
-                                       fontColor: "#666",
-                                       fontFamily: "Helvetica Neue",
-
-                                       //Boolean - Show a backdrop to the scale label
-                                       showLabelBackdrop: true,
-
-                                       //String - The colour of the label backdrop
-                                       backdropColor: "rgba(255,255,255,0.75)",
-
-                                       //Number - The backdrop padding above & below the label in pixels
-                                       backdropPaddingY: 2,
-
-                                       //Number - The backdrop padding to the side of the label in pixels
-                                       backdropPaddingX: 2,
-                               },
-
-                               pointLabels: {
-                                       //String - Point label font declaration
-                                       fontFamily: "'Arial'",
-
-                                       //String - Point label font weight
-                                       fontStyle: "normal",
-
-                                       //Number - Point label font size in pixels
-                                       fontSize: 10,
-
-                                       //String - Point label font colour
-                                       fontColor: "#666",
-                               },
                        },
 
                        elements: {
index 6711dfbaae36c5047d4b747ddc9f0dfcbe602061..fb2f101fe1e7c4723accce777505127d49645d28 100644 (file)
@@ -18,6 +18,8 @@
                        }],
                        yAxes: [{
                                type: "linear",
+                               position: "left",
+                               id: "y-axis-1",
                        }],
                },
 
index 1cb6fafc7b9c79de353b61d3c1e5d52af41f2265..28eef831dc054a2ce9acc49a285f6a12a25c1d59 100755 (executable)
                                                        // Scale config merging is complex. Add out own function here for that
                                                        base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value);
 
-                                               } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) {
+                                               } else if (key === 'scale') {
+                                                       // Used in polar area & radar charts since there is only one scale
+                                                       base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value);
+                                               }else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) {
                                                        // In this case we have an array of objects replacing another array. Rather than doing a strict replace,
                                                        // merge. This allows easy scale option merging
                                                        var baseArray = base[key];
index 9d8e30eff45cc0474a85889607eb2cb061f2f597..b15c487a373a6d14a830107d5f1169eee064e8a1 100644 (file)
@@ -5,6 +5,67 @@
                Chart = root.Chart,
                helpers = Chart.helpers;
 
+       var defaultConfig = {
+               display: true,
+
+               //Boolean - Whether to animate scaling the chart from the centre
+               animate: false,
+
+               lineArc: false,
+
+               // grid line settings
+               gridLines: {
+                       show: true,
+                       color: "rgba(0, 0, 0, 0.1)",
+                       lineWidth: 1,
+               },
+
+               angleLines: {
+                       show: true,
+                       color: "rgba(0,0,0, 0.1)",
+                       lineWidth: 1
+               },
+
+               // scale numbers
+               beginAtZero: true,
+
+               // label settings
+               labels: {
+                       show: true,
+                       template: "<%=value.toLocaleString()%>",
+                       fontSize: 12,
+                       fontStyle: "normal",
+                       fontColor: "#666",
+                       fontFamily: "Helvetica Neue",
+
+                       //Boolean - Show a backdrop to the scale label
+                       showLabelBackdrop: true,
+
+                       //String - The colour of the label backdrop
+                       backdropColor: "rgba(255,255,255,0.75)",
+
+                       //Number - The backdrop padding above & below the label in pixels
+                       backdropPaddingY: 2,
+
+                       //Number - The backdrop padding to the side of the label in pixels
+                       backdropPaddingX: 2,
+               },
+
+               pointLabels: {
+                       //String - Point label font declaration
+                       fontFamily: "'Arial'",
+
+                       //String - Point label font weight
+                       fontStyle: "normal",
+
+                       //Number - Point label font size in pixels
+                       fontSize: 10,
+
+                       //String - Point label font colour
+                       fontColor: "#666",
+               },
+       };
+
        var LinearRadialScale = Chart.Element.extend({
                initialize: function() {
                        this.size = helpers.min([this.height, this.width]);
                        }
                }
        });
-       Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale);
+       Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig);
 
 
 }).call(this);