Iker Aguayo
Iker Aguayo

Reputation: 4115

Launch Highcharts zooming programmatically (after a selection)

The xAxis of my charts is represented with days (xAxisType=dateTime).

I modify the selection event (zooming) and depend on the amount of days which are selected in the selection, the chart data is recalculated and the xAxis change to hours (instead of days). And the same process happens if we do another selection in the new chart (data recalculation and xAxis change to ten minutes, instead of hours).

Imagine that we have dates from 1st of February to 25th of February in the chart. If we select the 2nd and 3rd of February, the new recalculated data is shown with hours in the xAxis (now we have in the xAxis from 2nd February 00:00 to 3rd February 23:00, 48 ticks). And if we select again a new period (for example from 2nd February 07:00 to 2nd February 10:00) the new recalculated data is shown but in the xAxis appear ten minutes ticks. Important about this last thing, all the day is shown (24 hours divided in ten minutes ticks) not only the selected period.

The question is, is it any way of launching the regular Highcharts zooming with the selected period (from 2nd February 07:00 to 2nd February 10:00) after this last selection (programmatically)?

With this, appears directly the selected period instead the whole day, and I have the chance to push the button “reset the zoom” and get the whole day (what I have now).

I use Highcharts with Dojo.

Upvotes: 4

Views: 9566

Answers (3)

Mike Milkman
Mike Milkman

Reputation: 633

Looks like this.zoom() does not trigger chart.events.selection event.

In case you need to reset zoom and trigger all events along the way click on "Reset button" programmatically

$('.highcharts-button').click();

Upvotes: 0

Jabran Saeed
Jabran Saeed

Reputation: 6168

Im guessing you need to programaticaly reset the zoom. This is a better option than enabling the default highcharts zoom reset label. Since that would require an extra redundant step.

this.zoom()

Thanks.

Upvotes: 2

Paweł Fus
Paweł Fus

Reputation: 45079

To set extremes use:

this.xAxis[0].setExtremes(min,max);
this.showResetZoom();

Upvotes: 20

Related Questions