]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
suggestedMin and suggestedMax options for scales
authoretimberg <evert.timberg@gmail.com>
Sat, 31 Oct 2015 15:01:40 +0000 (11:01 -0400)
committeretimberg <evert.timberg@gmail.com>
Sat, 31 Oct 2015 15:01:40 +0000 (11:01 -0400)
samples/line.html
src/scales/scale.linear.js

index e83f488fa42daa28c6ac78a2fe38bee1dcc01da1..45cd9229ca9979bf2f1f700e9fc065d225d86878 100644 (file)
@@ -30,7 +30,8 @@
     </div>
     <script>
         var randomScalingFactor = function() {
-            return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1));
+            return Math.round(Math.random() * 100);
+            //return 0;
         };
         var randomColorFactor = function() {
             return Math.round(Math.random() * 255);
                         scaleLabel: {
                             show: true,
                             labelString: 'Value'
+                        },
+                        ticks: {
+                            suggestedMin: -10,
+                            suggestedMax: 250,
                         }
                     }]
                 }
index 78c02a2eac5835070890276b0fc2a5b42bc9ad73..e4cc4fd34fcab5e434fbd50af34226ab17471103 100644 (file)
                                        // move the botttom down to 0
                                        this.min = 0;
                                }
-                       } 
+                       }
+
+                       if (this.options.ticks.suggestedMin) {
+                               this.min = Math.min(this.min, this.options.ticks.suggestedMin);
+                       }
+
+                       if (this.options.ticks.suggestedMax) {
+                               this.max = Math.max(this.max, this.options.ticks.suggestedMax);
+                       }
 
                        if (this.min === this.max) {
                                this.min--;