Skip to content

How to display scale labels and set yAxes min/max? #1979

@evanb2

Description

@evanb2

I'm having trouble displaying the xAxes and yAxes scale labels, as well as setting the yAxes min/max.

I need the yAxes ticks to range from -10 to 120 in increments of 10....this was super easy to do in v1 but I had to switch to v2.0 in order to invert the yAxes...help would be much appreciated :)

Tried setting it up in a jsfiddle but couldn't get it to work, sorry.

Here's my Line object:

var chart = new Chart(context, {
    type: 'line',
    data: data,
    options: {
        scales: {
            xAxes: [
                {
                    position: "top",
                    scaleLabel: {
                        display: true,
                        labelString: "Frequency (Hz)",
                        fontFamily: "Montserrat",
                        fontColor: "black",
                    },
                    ticks: {
                        fontFamily: "Montserrat",
                    }
                }
            ],
            yAxes: [
                {
                    position: "left",
                    scaleLabel: {
                        display: true,
                        labelString: "dB",
                        fontFamily: "Montserrat",
                        fontColor: "black",
                    },
                    ticks: {
                        fontFamily: "Montserrat",
                        reverse : true,
                        min: -10,
                        max: 120,
                    },
                }
            ],
        },
    }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions