Home Forums Chart Support Bar Graph 2 axis but same max value?

Bar Graph 2 axis but same max value?

Viewing 3 posts - 1 through 3 (of 3 total)
  • #39510


    Sorry for my english. I’ll try to explain the best I can.

    I’m actually trying CanvasJS with a double axis on a bar graph. I’m using different value on both axis but I wan’t them to be “compared” with the same max value.

    Bar Graph

    On the screen, I put 2 red circle over the max value of both axis. I wan’t them to be the same (take the highted value of both Y axis and used it for both graph).
    So, both need to be at 4000 on this screen.

    I search a lot on the documentation but I can’t find what I’m looking for. Maybe someone here can help me?

    Thank a lot for your help !
    Wish you a great day!



    With the help of get method, you can get to know the maximum of primary y-axis. Once you get the maximum of primary y-axis, you can use set method to set the maximum of secondary y-axis. Below is the code-snippet to do so.
    chart.axisY2[0].set("maximum", chart.axisY[0].get("maximum"));

    Vishwas R
    Team CanvasJS



    Thank your for your help.

    It work great. But it will only set Y2 axis with the maximum value of Y axis. But I need it to be dynamic. If Y2 is > than Y1, than use Y2 maximum value, else, use Y1 maximum value.

    Maybe, with the get method, I can combine with javascript if function like :

    if (chart.axisY[0].get("maximum") >= chart.axisY2[0].get("maximum")) {
         chart.axisY2[0].set("maximum", chart.axisY[0].get("maximum"));
    } else {
        chart.axisY[0].set("maximum", chart.axisY2[0].get("maximum"));

    I still didn’t try this code yet. If there is a best method with canjavjs function, would be happy to learn it.

    Thank you !

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.