highcharts / highcharts-ios

iOS wrapper for Highcharts.
Other
127 stars 39 forks source link

how can i set to zoom in level when chart load initially. #356

Closed pruharikantamipara closed 3 years ago

pruharikantamipara commented 3 years ago

Hello i need to set zoom in default when my chart is initially loading. i have attached screenshot for better understanding. one screenshot is default chart loading & second is zoom in using pinch zoom. so i required same zoom in level without pinch zoom.

Default Chart

required zoom in chart

ihnatmoisieiev commented 3 years ago

Hello @pruharikantamipara, you can achieve that by setting extremes after your chart is finished loading, eg.

chart.events = HIEvents()
chart.events.load = HIFunction(jsFunction: "function () { this.xAxis[0].setExtremes(min, max); }")

Just replace min and max with proper values.

pruharikantamipara commented 3 years ago

thank you for the help me. i have set above code and working fine. but is there any way to set zoom level without getting min max value from console?

ihnatmoisieiev commented 3 years ago

@pruharikantamipara you can use any values you need. Please check API of setExtremes method.

pruharikantamipara commented 3 years ago

can you please provide me the demo code for setExtremes.

ihnatmoisieiev commented 3 years ago

@pruharikantamipara sure.

chart.events.load = HIFunction(jsFunction: "function () { this.xAxis[0].setExtremes(0, 5); }")

and on HIXaxis or HIYAxis object:

let xAxis = chart.options.xAxis.first!

xAxis.setExtremes()
xAxis.setExtremes(0)
xAxis.setExtremes(0, newMax: 5)
xAxis.setExtremes(0, newMax: 5, redraw: false)

let animation = HIAnimationOptionsObject()
animation.duration = 0
xAxis.setExtremes(0, newMax: 5, redraw: false, animation: animation)
pruharikantamipara commented 3 years ago

Hello @ihnatmoisieiev i have tired last solution xAxis.setExtremes(min, max: 5, redraw: false) but isn't work well.

so i try with this code chart.events.load = HIFunction(jsFunction: "function () { this.xAxis[0].setExtremes(min, max); }") and its working fine.

ihnatmoisieiev commented 3 years ago

@pruharikantamipara when you need to get it on init, use chart.events.load = HIFunction(jsFunction: "function () { this.xAxis[0].setExtremes(min, max); }").

pruharikantamipara commented 3 years ago

Hello @ihnatmoisieiev my query resolved. i do not have any query now. thank you.