Home>

At chart.js, we are creating a radar chart for each test subject. "5" is the best, but this time "1" is the best. I'm having trouble drawing.
Label
["Overall","National Language","Mathematics","English"]
Data
["2","4","1","2"]

If the radar chart drawing is "5" is the best in the normal five-level evaluation,

Excerpt of options part of drawing
var options = {
    scale: {
        ticks: {
            beginAtZero: true,
            max: 5,
            min: 1,
            stepSize: 1,
            display: true
        }
    }
};


You can draw with, but trying to optimize "1",

var options = {
    scale: {
        ticks: {
            beginAtZero: true,
            max: 1,
            min: 5,
            stepSize: 1,
            display: true
        }
    }
};


Of course, it won't work if you reverse max and min.

Manipulating the data itself, normalizing 5 as the maximum value (0 to 1) and max = 1, min = 0, or subtracting each data from the maximum value 5 (log?) 5, If min = 1, the drawing itself can be done well, but it is not a problem because the numerical value after the calculation will appear in the scale value and tooltips on mouse over.

tooltips has an event, and the tooltips value can be rewritten, but there is no description to control the tick value by the event. .

Someone knows a good way?

  • Answer # 1

    I'm sorry, I found a tick value event and rewritten the notation.

    Variable for tooltips display (actual value)

    var hyouka = ​​["2", "4", "1", "2"];

    The value of dataset.data is 6-the above value (6 is not 5 because 1 is the maximum)

    data: ["4", "2", "5", "4"]
    options
    var options = {
        scale: {
            ticks: {
                callback: function (value) {return 6-value},
                beginAtZero: false,
                max: 1,
                min: 5,
                stepSize: 1,
                display: true
            }
        }
    };


    Only the apparent value was set to "maximum value + 1−real number", and the tooltips were set to real values.