Skip to content

Commit

Permalink
fix #11503, autoskipping 0 ticks when min is below 0 (#11682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megaemce committed Feb 24, 2024
1 parent ef5e4d4 commit 4068bd8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scales/scale.radialLinear.js
Expand Up @@ -578,7 +578,7 @@ export default class RadialLinearScale extends LinearScaleBase {

if (grid.display) {
this.ticks.forEach((tick, index) => {
if (index !== 0) {
if (index !== 0 || (index === 0 && this.min < 0)) {
offset = this.getDistanceFromCenterForValue(tick.value);
const context = this.getContext(index);
const optsAtIndex = grid.setContext(context);
Expand Down Expand Up @@ -645,7 +645,7 @@ export default class RadialLinearScale extends LinearScaleBase {
ctx.textBaseline = 'middle';

this.ticks.forEach((tick, index) => {
if (index === 0 && !opts.reverse) {
if ((index === 0 && this.min >= 0) && !opts.reverse) {
return;
}

Expand Down
45 changes: 45 additions & 0 deletions test/fixtures/scale.radialLinear/ticks-below-zero.js
@@ -0,0 +1,45 @@
module.exports = {
config: {
type: 'radar',
data: {
labels: ['A', 'B', 'C', 'D', 'E']
},
options: {
responsive: false,
scales: {
r: {
min: -1,
max: 1,
grid: {
display: true,
color: 'blue',
lineWidth: 2
},
angleLines: {
color: 'rgba(255, 255, 255, 0.5)',
lineWidth: 2
},
pointLabels: {
display: false
},
ticks: {
display: true,
autoSkip: false,
stepSize: 0.2,
callback: function(value) {
if (value === 0.8) {
return 'Strong';
}
if (value === 0.4) {
return 'Weak';
}
if (value === 0) {
return 'No';
}
}
}
}
}
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4068bd8

Please sign in to comment.