diff --git a/docs/01-Scales.md b/docs/01-Scales.md index 5d8b35a09..4fd8aa204 100644 --- a/docs/01-Scales.md +++ b/docs/01-Scales.md @@ -49,6 +49,7 @@ Chart.defaults.scale = { fontStyle: "normal", fontColor: "#666", fontFamily: "Helvetica Neue", + maxTicksLimit: 11, maxRotation: 90, minRotation: 20, mirror: false, @@ -208,6 +209,9 @@ The radial linear scale extends the core scale class with the following tick tem //Number - The backdrop padding to the side of the label in pixels backdropPaddingX: 2, + + //Number - Limit the maximum number of ticks + maxTicksLimit: 11, }, pointLabels: { diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index ac8954fa1..ef7db5b6f 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -125,10 +125,12 @@ var maxTicks; if (this.isHorizontal()) { - maxTicks = Math.min(11, Math.ceil(this.width / 50)); + maxTicks = Math.min(this.options.ticks.maxTicksLimit ? this.options.ticks.maxTicksLimit : 11, + Math.ceil(this.width / 50)); } else { // The factor of 2 used to scale the font size has been experimentally determined. - maxTicks = Math.min(11, Math.ceil(this.height / (2 * this.options.ticks.fontSize))); + maxTicks = Math.min(this.options.ticks.maxTicksLimit ? this.options.ticks.maxTicksLimit : 11, + Math.ceil(this.height / (2 * this.options.ticks.fontSize))); } // Make sure we always have at least 2 ticks diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 75ef7a958..15fdb3626 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -101,7 +101,8 @@ // the axis area. For now, we say that the minimum tick spacing in pixels must be 50 // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on // the graph - var maxTicks = Math.min(11, Math.ceil(this.drawingArea / (1.5 * this.options.ticks.fontSize))); + var maxTicks = Math.min(this.options.ticks.maxTicksLimit ? this.options.ticks.maxTicksLimit : 11, + Math.ceil(this.drawingArea / (1.5 * this.options.ticks.fontSize))); maxTicks = Math.max(2, maxTicks); // Make sure we always have at least 2 ticks // To get a "nice" value for the tick spacing, we will use the appropriately named