]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Create linear scale default settings. Cleaned up unnecessary settings from bar, line...
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 13 Jun 2015 17:57:55 +0000 (13:57 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 13 Jun 2015 17:57:55 +0000 (13:57 -0400)
samples/bar-multi-axis.html
samples/bar-stacked.html
samples/line-multi-axis.html
samples/line.html
samples/scatter-multi-axis.html
src/charts/chart.bar.js
src/charts/chart.line.js
src/charts/chart.scatter.js
src/scales/scale.linear.js

index cdb573007e96ce115e904d3188fb378537413350..d6ae259515643acfac5f1be489607b8cf7557a31 100644 (file)
                         display: true,
                         position: "left",
                         id: "y-axis-1",
-                
-                        // grid line settings
-                        gridLines: {
-                            show: true,
-                            color: "rgba(0, 0, 0, 0.05)",
-                            lineWidth: 1,
-                            drawOnChartArea: true,
-                            drawTicks: true,
-                            zeroLineWidth: 1,
-                            zeroLineColor: "rgba(0,0,0,0.25)",
-                        },
-
-                        // scale numbers
-                        beginAtZero: false,
-                        integersOnly: false,
-                        override: null,
-
-                        // label settings
-                        labels: {
-                            show: true,
-                            template: "<%=value%>",
-                            fontSize: 12,
-                            fontStyle: "normal",
-                            fontColor: "#666",
-                            fontFamily: "Helvetica Neue",
-                        }
                     }, {
                         type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                         display: true,
                         position: "right",
                         id: "y-axis-2",
-                
-                        // grid line settings
                         gridLines: {
-                            show: true,
-                            color: "rgba(0, 0, 0, 0.05)",
-                            lineWidth: 1,
-                            drawOnChartArea: false, // only want the grid lines for one axis to show up
-                            drawTicks: false,
-                            zeroLineWidth: 1,
-                            zeroLineColor: "rgba(0,0,0,0.25)",
-                        },
-
-                        // scale numbers
-                        beginAtZero: false,
-                        integersOnly: false,
-                        override: null,
-
-                        // label settings
-                        labels: {
-                            show: true,
-                            template: "<%=value%>",
-                            fontSize: 12,
-                            fontStyle: "normal",
-                            fontColor: "#666",
-                            fontFamily: "Helvetica Neue",
+                            drawOnChartArea: false
                         }
                     }],
                 }
index 1d7257f3de7aa6c2718707cd8b4f680ab88c0618..573be2c183c1210f513dce6e2590e6fda4e9677e 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 
 <head>
-    <title>Bar Chart</title>
+    <title>Stacked Bar Chart</title>
     <script src="../node_modules/jquery/dist/jquery.min.js"></script>
     <script src="../Chart.js"></script>
 </head>
@@ -44,6 +44,9 @@
             options: {
                 responsive: true,
                 scales: {
+                    xAxes: [{
+                        stacked: true,
+                    }],
                     yAxes: [{
                         stacked: true
                     }]
index 97833376e732fe1422fa47504884d983dc6561e7..729cf3731b2e5a904fbb53ed2d17a79391aadb12 100644 (file)
                         display: true,
                         position: "left",
                         id: "y-axis-1",
-
-                        // grid line settings
-                        gridLines: {
-                            show: true,
-                            color: "rgba(0, 0, 0, 0.05)",
-                            lineWidth: 1,
-                            drawOnChartArea: true,
-                            drawTicks: true,
-                            zeroLineWidth: 1,
-                            zeroLineColor: "rgba(0,0,0,0.25)",
-                        },
-
-                        // scale numbers
-                        beginAtZero: false,
-                        integersOnly: false,
-                        override: null,
-
-                        // label settings
-                        labels: {
-                            show: true,
-                            template: "<%=value%>",
-                            fontSize: 12,
-                            fontStyle: "normal",
-                            fontColor: "#666",
-                            fontFamily: "Helvetica Neue",
-                        }
                     }, {
                         type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                         display: true,
 
                         // grid line settings
                         gridLines: {
-                            show: true,
-                            color: "rgba(0, 0, 0, 0.05)",
-                            lineWidth: 1,
                             drawOnChartArea: false, // only want the grid lines for one axis to show up
-                            drawTicks: false,
-                            zeroLineWidth: 1,
-                            zeroLineColor: "rgba(0,0,0,0.25)",
                         },
-
-                        // scale numbers
-                        beginAtZero: false,
-                        integersOnly: false,
-                        override: null,
-
-                        // label settings
-                        labels: {
-                            show: true,
-                            template: "<%=value%>",
-                            fontSize: 12,
-                            fontStyle: "normal",
-                            fontColor: "#666",
-                            fontFamily: "Helvetica Neue",
-                        }
                     }],
                 }
             }
index 82ca744c55ea232e2200318d3a184e18091de0a9..a20b6773e27527c9172a5949eb2ca796fd9b0e79 100644 (file)
             responsive: true,
             scales: {
                 xAxes: [{
-                    display: false
+                    display: true
                 }],
                 yAxes: [{
-                    display: false
+                    display: true
                 }]
             }
         }
index 45e0cbed53b9c952607dcad0d3cc27ca8e3bf888..ab08e0d264891d82d7a7b624cc00556048ea86b0 100644 (file)
                                display: true,
                                position: "left",
                                id: "y-axis-1",
-                       
-                               // grid line settings
-                               gridLines: {
-                                   show: true,
-                                   color: "rgba(0, 0, 0, 0.05)",
-                                   lineWidth: 1,
-                                   drawOnChartArea: true,
-                                   drawTicks: true,
-                                   zeroLineWidth: 1,
-                                   zeroLineColor: "rgba(0,0,0,0.25)",
-                               },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               integersOnly: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                   show: true,
-                                   template: "<%=value%>",
-                                   fontSize: 12,
-                                   fontStyle: "normal",
-                                   fontColor: "#666",
-                                   fontFamily: "Helvetica Neue",
-                               }
                            }, {
                                type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                                display: true,
                        
                                // grid line settings
                                gridLines: {
-                                   show: true,
-                                   color: "rgba(0, 0, 0, 0.05)",
-                                   lineWidth: 1,
                                    drawOnChartArea: false, // only want the grid lines for one axis to show up
-                                   drawTicks: false,
-                                   zeroLineWidth: 1,
-                                   zeroLineColor: "rgba(0,0,0,0.25)",
                                },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               integersOnly: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                   show: true,
-                                   template: "<%=value%>",
-                                   fontSize: 12,
-                                   fontStyle: "normal",
-                                   fontColor: "#666",
-                                   fontFamily: "Helvetica Neue",
-                               }
                            }],
                    }
                }
index d83b25b44a32b7adc6b99eaed6a3ccc11598fd4d..1cba8b9b56ef1f7b893932f8206010d2ae91cf8f 100644 (file)
                        }],
                        yAxes: [{
                                type: "linear",
-                               display: true,
-                               position: "left",
-                               id: "y-axis-1",
-
-                               spacing: 1,
-
-                               // grid line settings
-                               gridLines: {
-                                       show: true,
-                                       color: "rgba(0, 0, 0, 0.05)",
-                                       lineWidth: 1,
-                                       drawOnChartArea: true,
-                                       drawTicks: true, // draw ticks extending towards the label
-                                       zeroLineWidth: 1,
-                                       zeroLineColor: "rgba(0,0,0,0.25)",
-                               },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                       show: true,
-                                       template: "<%=value%>",
-                                       fontSize: 12,
-                                       fontStyle: "normal",
-                                       fontColor: "#666",
-                                       fontFamily: "Helvetica Neue",
-                               }
                        }],
                },
 
index 97b3e1ef208cd0775a005ed670f8c547e42d039b..64f2158f9d51a31f0e6eeb96f76e57c9a762fb11 100644 (file)
 
                scales: {
                        xAxes: [{
-                               type: "category", // scatter should not use a dataset axis
+                               type: "category",
                        }],
                        yAxes: [{
-                               type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
-                               display: true,
-                               position: "left",
-                               id: "y-axis-1",
-
-                               // grid line settings
-                               gridLines: {
-                                       show: true,
-                                       color: "rgba(0, 0, 0, 0.05)",
-                                       lineWidth: 1,
-                                       drawOnChartArea: true,
-                                       drawTicks: true, // draw ticks extending towards the label
-                                       zeroLineWidth: 1,
-                                       zeroLineColor: "rgba(0,0,0,0.25)",
-                               },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                       show: true,
-                                       template: "<%=value.toLocaleString()%>",
-                                       fontSize: 12,
-                                       fontStyle: "normal",
-                                       fontColor: "#666",
-                                       fontFamily: "Helvetica Neue",
-                               }
+                               type: "linear",
                        }],
                },
        };
index a3ae03062493d78f9994b401bd9182be5b702526..6711dfbaae36c5047d4b747ddc9f0dfcbe602061 100644 (file)
 
                scales: {
                        xAxes: [{
-                               type: "linear", // scatter should not use a dataset axis
-                               display: true,
+                               type: "linear", // scatter should not use a category axis
                                position: "bottom",
                                id: "x-axis-1", // need an ID so datasets can reference the scale
-
-                               // grid line settings
-                               gridLines: {
-                                       show: true,
-                                       color: "rgba(0, 0, 0, 0.05)",
-                                       lineWidth: 1,
-                                       drawOnChartArea: true,
-                                       drawTicks: true,
-                                       zeroLineWidth: 1,
-                                       zeroLineColor: "rgba(0,0,0,0.25)",
-                               },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                       show: true,
-                                       template: "<%=value.toLocaleString()%>",
-                                       fontSize: 12,
-                                       fontStyle: "normal",
-                                       fontColor: "#666",
-                                       fontFamily: "Helvetica Neue",
-                               },
                        }],
                        yAxes: [{
-                               type: "linear", // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
-                               display: true,
-                               position: "left",
-                               id: "y-axis-1",
-
-                               // grid line settings
-                               gridLines: {
-                                       show: true,
-                                       color: "rgba(0, 0, 0, 0.05)",
-                                       lineWidth: 1,
-                                       drawOnChartArea: true,
-                                       drawTicks: true, // draw ticks extending towards the label
-                                       zeroLineWidth: 1,
-                                       zeroLineColor: "rgba(0,0,0,0.25)",
-                               },
-
-                               // scale numbers
-                               beginAtZero: false,
-                               override: null,
-
-                               // label settings
-                               labels: {
-                                       show: true,
-                                       template: "<%=value.toLocaleString()%>",
-                                       fontSize: 12,
-                                       fontStyle: "normal",
-                                       fontColor: "#666",
-                                       fontFamily: "Helvetica Neue",
-                               }
+                               type: "linear",
                        }],
                },
 
index fd4e6d80034c0f155896c93bcfd265c5e44b7196..0ddd956b5417cba1c4412d49a8cc85536678844c 100644 (file)
@@ -5,6 +5,37 @@
                Chart = root.Chart,
                helpers = Chart.helpers;
 
+       var defaultConfig = {
+               display: true,
+               position: "left",
+               id: "y-axis-1",
+
+               // grid line settings
+               gridLines: {
+                       show: true,
+                       color: "rgba(0, 0, 0, 0.1)",
+                       lineWidth: 1,
+                       drawOnChartArea: true,
+                       drawTicks: true, // draw ticks extending towards the label
+                       zeroLineWidth: 1,
+                       zeroLineColor: "rgba(0,0,0,0.25)",
+               },
+
+               // scale numbers
+               beginAtZero: false,
+               override: null,
+
+               // label settings
+               labels: {
+                       show: true,
+                       template: "<%=value.toLocaleString()%>",
+                       fontSize: 12,
+                       fontStyle: "normal",
+                       fontColor: "#666",
+                       fontFamily: "Helvetica Neue",
+               }
+       };
+
        var LinearScale = Chart.Element.extend({
                calculateRange: helpers.noop, // overridden in the chart. Will set min and max as properties of the scale for later use
                isHorizontal: function() {
                        }
                }
        });
-       Chart.scaleService.registerScaleType("linear", LinearScale);
-       
+       Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);
+
 }).call(this);