Skip to content

Not displaying tick zero value in callback for radar chart with scale's min below zero #11503

@Megaemce

Description

@Megaemce

Expected behavior

By default when creating radar chart the tick's zero value is not displayed.
However when the scale's min value is changed it's shown again. When user set a tick's callback, the zero should be handled and displayed just like any other value.

           r: {
                    min: -0.3,
                    max: 1,
                    ticks: {
                        autoSkip: false,
                        stepSize: 0.1,
                        // callback to display only few values
                        callback: function (value) {
                            if (value === 0.9) return "very strong";
                            if (value === 0.7) return "strong";
                            if (value === 0.4) return "moderate";
                            if (value === 0.2) return "weak";
                            if (value === 0) return "no"; // this should be displayed just like any other value
                        },
                    },
                },
         

image

Current behavior

When tick's callback is set the zero value will not be shown. The only possible (and dirty) workaround is to return all the values like so:

callback: function (value) {
           if (value === 0.9) return "very strong";
           if (value === 0.7) return "strong";
           if (value === 0.4) return "moderate";
           if (value === 0.2) return "weak";
           if (value === 0) return "no";
           return ""; // dirty workaround showing all the values
},

image

Reproducible sample

https://codepen.io/kowal66b/pen/vYvJryv

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

I want show only limited amount of ticks with zero value as well

chart.js version

4.4.0

Browser name and version

No response

Link to your project

www.correlations.world

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions