From 97da3347beb1785e2dce0ae3433f0225c7161bd2 Mon Sep 17 00:00:00 2001 From: Pascal Richier Date: Sat, 7 Nov 2015 01:37:09 +0100 Subject: [PATCH 1/4] Add options.ticks.maxTicksLimit To be able to change default '11' value --- src/scales/scale.linear.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 From d5d63070c6f279b35f92acac53ea4f9a933ce8d9 Mon Sep 17 00:00:00 2001 From: Pascal Richier Date: Sat, 7 Nov 2015 01:39:30 +0100 Subject: [PATCH 2/4] Add options.ticks.maxTicksLimit To be able to change default '11' value --- src/scales/scale.radialLinear.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 178880bace3a9091db8bd2bc3ac55b6c48552a70 Mon Sep 17 00:00:00 2001 From: Pascal Richier Date: Sat, 7 Nov 2015 01:42:19 +0100 Subject: [PATCH 3/4] Update doc for options.ticks.maxTicksLimit --- docs/01-Scales.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/01-Scales.md b/docs/01-Scales.md index 5d8b35a09..ac9682d11 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, From 3d15e1ff54045e7f449139a2fc8e70e29d558fd2 Mon Sep 17 00:00:00 2001 From: Pascal Richier Date: Sat, 7 Nov 2015 01:46:14 +0100 Subject: [PATCH 4/4] Update doc for options.ticks.maxTicksLimit --- docs/01-Scales.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/01-Scales.md b/docs/01-Scales.md index ac9682d11..4fd8aa204 100644 --- a/docs/01-Scales.md +++ b/docs/01-Scales.md @@ -209,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: {