Is it possible for Chartjs to build a graph with two different scales? Or what alternative would you recommend for this? Or is it only in paid libraries?

1 Answers 1

There is.See examples in the documentation, multi axis.

UPD.What the author of the question really wanted: the discussion in the comments was the schedule was made with switching the visibility of axes depending on the visibility of the corresponding data set(an example is taken from the line chart multi axis from the documentation).
  • Yes, drew attention to this option. But for complete happiness, there is not enough opportunity to name the scales of the chart and hide the scales when one of the parameters is turned off: ( – Thoughtful Toucan Sep 25 '18 at 07:49
  • Thoughtful Toucan, I did not understand anything.

    lacks the ability to name graph scales

    What are the names, what is it?

    their cover at

    "Krytii"? This is what language is spoken?
    – The66 Sep 25 '18 at 08:12
  • What are the names, what is it?

    Well, so that each individual scale would be named, in other words, I already figured it out, this is how it looks:
     scales: {yAxes: [{scaleLabel: {display: true, labelString:'Once'}, type:'linear', //linearly scale, registration. For instance display: true, position:'left', id:'y-axis-1',}, {scaleLabel: {display: true, labelString:'Two'}, type:'linear', //only linear but allow scale type registration. For instance display: true, position:'left', id:'y-axis-2',}, {type:'linear', //). For instance: for example, display grid, grid line, grid line: {drawOnChartArea: false, //only want the grid lines for one axis to show up},}],}


    Yes, it’s hard when you don’t know JS :(

    Krytia? Is it on what language does it say?


    Corrected. Well, that is, if I crossed out (hid the parameter), then the scale responsible for it would also disappear. That is, by analogy, as in Highcharts. I am afraid This without JS knowledge, namely working with conditions, I can not cope :(
    – Thoughtful Toucan Sep 25 '18 at 08:44
  • Thoughtful Toucan,

    so that the scale responsible for it also disappears

    There is a display property;by default it is true. Assigning false, pulling the update method will disappear. For example (a couple of buttons above the graph, the click handler is at the bottom).

    And for this crap to work by clicking on dataset's labels, you can define a handler
     options: {legend: {onClick (event, labelItem) {//determine which datasets are hidden/visible, well, hide/show the corresponding chart axes}},}
    – The66 Sep 25 '18 at 08:52
  • Yes, I understood about the display, this method is used there in many positions. But I don’t know about update, is it you who say that with window.myLine.update() ;?
    For example (a couple of buttons above the graph, a click handler at the very bottom).

    Well, I understand how to implement this through HTML, I just thought that you can do it through js, that is, if you hide the graph, then the measurement scale is hidden...
    Tell me in JS can this be realized? How to fulfill the conditions there? Or in JS there are no such things as if? Tell me about exactly what to look for information regarding JS?
    – Thoughtful Toucan Sep 25 '18 at 10:20
  • Thoughtful Toucan,

    I don’t know about update, do you speak about it with window.myLine.update();?

    For graphs chart.js there is an update method, I'm talking about it (see the example from the link from my previous comment). What is myLine - I have no idea.

    Or in JS there are no such things as if at all?

    T-aaaaaaaa, yasnenko. Oh, I’m definitely not going to teach you the basics of JS. Go to freelance, pay money, they will do everything there.
    – The66 Sep 25 '18 at 10:28
  • The66,

    Charts chart.js have an update method, I'm talking about it (see the example from the link from my previous comment).

    I understand you say this part of the code?
     if (axis) {axis.display =! axis.display;ch.update();}

    Do I understand correctly that when I press a button, the display returns the opposite of its value, after which the graph (ie, ch) is reloaded with the update command?

    T-aaaaaaa, clear. Oh, I’m definitely not going to teach you the basics of JS. Go to freelance, pay the money, they will do everything there.

    Okay, okay, I read it already, everything is there (in JS), I’ll think about how you can implement it through JS... here it is important to learn :)))
    – Thoughtful Toucan Sep 25 '18 at 10:44
  • Thoughtful Toucan, so here's example of how you can synchronize visibility axes with visibility dataset. Everything further on themselves. Delve, study. – The66 Sep 25 '18 at 11:09
  • The66, Thank you, I will understand :) At worst, I implement it through HTML :) – Thoughtful Toucan Sep 25 '18 at 11:10