Merge pull request #1407 from etimberg/fix/category-filter-lines

Allow hiding grid lines using the filter function in the category scale
This commit is contained in:
Evert Timberg 2015-08-23 13:24:58 -04:00
commit 8164418dc8
3 changed files with 6 additions and 2 deletions

View File

@ -403,6 +403,9 @@ The `userCallback` method may be useful when there are a lot of labels. The foll
xAxes: [{
labels: {
maxRotation: 0, // set maxRotation to 0 to turn off auto-rotation
// Return an empty string to draw the grid line but hide the label
// Return `null` or `undefined` to hide the grid line
userCallback: function(labelString, index) {
return (index % 5 === 0) ? labelString : '';
}

View File

@ -55,7 +55,7 @@
display: true,
labels: {
userCallback: function(dataLabel, index) {
return index % 2 === 0 ? dataLabel : '';
return index % 2 === 0 ? dataLabel : null;
}
}
}],

View File

@ -230,7 +230,8 @@
}
helpers.each(this.labels, function(label, index) {
if (skipRatio > 1 && index % skipRatio > 0) {
// Blank labels
if ((skipRatio > 1 && index % skipRatio > 0) || (label === undefined || label === null)) {
return;
}
var xLineValue = this.getPixelForValue(label, index, null, false); // xvalues for grid lines