mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
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:
commit
8164418dc8
@ -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 : '';
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
display: true,
|
||||
labels: {
|
||||
userCallback: function(dataLabel, index) {
|
||||
return index % 2 === 0 ? dataLabel : '';
|
||||
return index % 2 === 0 ? dataLabel : null;
|
||||
}
|
||||
}
|
||||
}],
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user