Merge pull request #1627 from pascoual/v2.0-dev

Add: options.ticks.maxTicksLimit
This commit is contained in:
Evert Timberg
2015-11-06 19:56:29 -05:00
3 changed files with 10 additions and 3 deletions

View File

@@ -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: {

View File

@@ -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

View File

@@ -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