Home Forums Chart Support Zoom out on change?

Zoom out on change?

Viewing 6 posts - 1 through 6 (of 6 total)
  • #21401

    I’m trying to zoom out if data input is changed so that the user doesn’t have to press reset/get confused of no values displayed.
    I tried with this function that I saw which almost has what i want. (source: https://canvasjs.com/docs/charts/how-to/sync-across-multiple-charts/)

    chart.options.axisX.viewportMinimum = chart.options.axisX.viewportMaximum = null;
    chart.options.axisY.viewportMinimum = chart.options.axisY.viewportMaximum = null;

    The thing is I want to keep my settings after reset and I can’t get it to work. What attribute should I set? I tried with several values on viewport before and it doesn’t look good. I just want a zoom out without changing the values if possible.

    const xAxis =  {
          suffix: prefix[0].concat(units[0]),
          maximum: xdiff,
          viewportMinimum: 0,
       const yAxis = {
        suffix: prefix[1].concat(units[1]),
        maximum: ydiff,


    Could you please create a sample project depicting your issue and share it over Onedrive or Google-Drive? So that we can look into the code, understand your scenario better and help you out.

    Priyanka M S
    Team CanvasJS


    lets turn the question instead, I want to do the same thing as the reset button does if the data is changed in a specific way.
    Is there a way to access that function from the api? Can’t share my code sorry.


    I already have the function that notices the change. I just need to reset the zoom and want to know how to do so without changing things.



    If viewportMinimum and viewportMaximum are not set/ reset, minimum and maximum values of axis will become the viewport’s range. So, when you are trying to reset viewportMinimum/viewportMaximum, do consider and reset minimum/maximum accordingly.

    Priyanka M S
    Team CanvasJS


    I just want the same functionality as the reset button does but I can’t find it so ill just have to click it…
    solved it..

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

You must be logged in to reply to this topic.