Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HighCharts render chart already zoomed

Is it possible to render a zoomable charts and have it already zoomed. I'm using a scatter plot which is zoomable on the x and y axis and would like to have it rendered already zoomed in to certain values.

Is there any default zooming options I can set when defining the chart?

Here is a working example of the chart: Chart Example

$('#container').highcharts({
    chart: {
        type: 'scatter',
        zoomType: 'xy'
    }...
like image 380
Ryan Gill Avatar asked Oct 31 '22 15:10

Ryan Gill


1 Answers

The chart.zoom function is available (but not intended for this use), but normally takes quite a few parameters from a drag-event. Faking it upon chart creation could at minimum be done like this:

$('#container').highcharts({
    // ...
}, function() {
    this.zoom({
        xAxis: [{ min: 25, max: 30, axis: this.xAxis[0] }], 
        yAxis: [{ min: 0, max: 300, axis: this.yAxis[0] }]
    });
});

See this CodePen for an example. If you do a manual selection I've logged the original input that function would take.

like image 188
Halvor Holsten Strand Avatar answered Nov 09 '22 08:11

Halvor Holsten Strand