Home Forums Chart Support Zoom out on change?

Zoom out on change?

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

    Hi,
    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 =  {
          title:labels[0],
          suffix: prefix[0].concat(units[0]),
          maximum: xdiff,
          viewportMinimum: 0,
        }
    
       const yAxis = {
        title:labels[1],
        suffix: prefix[1].concat(units[1]),
        maximum: ydiff,
        }
    
    #21404

    @slotmachine

    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

    #21426

    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.

    #21427

    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.

    #21585

    @slotmachine,

    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

    #21786

    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..
    document.getElementsByClassName('canvasjs-chart-toolbar')[0].children[1].click()

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

You must be logged in to reply to this topic.