edalmau
Posts: 3
Joined: Thu Oct 25, 2018 3:31 pm

iOS - How getting new extremes afterSetExtremes method event

We have implemented a zoomable line chart in an iOS app. We need to detect when user does a zoom event and get new extremes after zoom, and to achieve that, we have added an event to xAxis, exactly we have added the event afterSetExtremes. In the event we have included a function to get new extremes, but seams it does not work correctly.

The function is execute correctly when user zoom the graph, but we cannot get the new properties to get new extremes values. Does anyone know if there is a bug? or how to get it. We receive null value into event.min and event.max properties.

We have implemented code as following:

1. Event added to xAxis object:

HIXAxis *xaxis = [[HIXAxis alloc]init];
xaxis.type = @"datetime";
xaxis.events = event;


2. Event definition:

HIEvents *event = [[HIEvents alloc]init];
event.afterSetExtremes = function;


3. Function definition:

HIFunction * function = [[HIFunction alloc] initWithClosure:^(HIChartContext *context) {
NSNumber *min = [context getProperty:@"event.min"];
NSNumber *max = [context getProperty:@"event.max"];

NSLog(@"min value: %ld", min);
NSLog(@"max value: %ld", max);
} properties:@[@"event.min", @"event.max"]];



We have tried to get event.dataMin, event.dataMax, min, max, and we receive null to all properties. Does anybody know how to get new extremes after user zoom graph?

Thanks in advance

Eduard
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: iOS - How getting new extremes afterSetExtremes method e

Hi, Eduard!

Before I pass your issue to our IOS specialists, can I make sure that you are getting your extremes in the right way? You can use getExtremes() method: https://api.highcharts.com/class-refere ... etExtremes

jsFiddle example: https://jsfiddle.net/zqs1jpwo/

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead
edalmau
Posts: 3
Joined: Thu Oct 25, 2018 3:31 pm

Re: iOS - How getting new extremes afterSetExtremes method e

We do, but receive null values
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: iOS - How getting new extremes afterSetExtremes method e

Hi, Eduard!

Could you try to change your HIFunction for this:

Code: Select all

HIFunction *function = [[HIFunction alloc] initWithClosure:^(HIChartContext *context) {
NSNumber *min = [context getProperty:@"this.min"];
NSNumber *max = [context getProperty:@"this.max"];
NSNumber *dataMin = [context getProperty:@"this.dataMin"];
NSNumber *dataMax = [context getProperty:@"this.dataMax"];

NSLog(@"min value: %ld", min);
NSLog(@"max value: %ld", max);
NSLog(@"dataMin value: %ld", dataMin);
NSLog(@"dataMax value: %ld", dataMax);
} properties:@[@"this.min", @"this.max", @"this.dataMin", @"this.dataMax"]];
Let me know if everything works fine now.

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead
edalmau
Posts: 3
Joined: Thu Oct 25, 2018 3:31 pm

Re: iOS - How getting new extremes afterSetExtremes method e

Yes, now it is running ok

Great!

Return to “Highcharts Usage”