Question

I have a SChartLineSeries and when I select a point, the selectedPointStyle doesn't seem to get applied.

Here's my code:

-(SChartSeries*)sChart:(ShinobiChart *)chart seriesAtIndex:(NSInteger)index {
   SChartLineSeries* lineSeries = [[SChartLineSeries alloc] init];

   lineSeries.selectionMode = SChartSelectionPoint;

   SChartLineSeriesStyle *style = [SChartLineSeriesStyle new];
   style.pointStyle = [SChartPointStyle new];
   style.pointStyle.showPoints = YES;
   style.pointStyle.color = [UIColor whiteColor];
   style.pointStyle.radius = [NSNumber numberWithInt:5];
   //style.pointStyle.innerRadius = [NSNumber numberWithFloat:0.0];
   style.selectedPointStyle.color = [UIColor orangeColor];
   style.selectedPointStyle.radius = [NSNumber numberWithInt:15];

   [lineSeries setStyle:style];
   //[lineSeries setSelectedStyle:style];
}

Please help. We're in a crunch time. Also, if I have to customize to show a dashed line, is it possible to do so in Shinobi?

Was it helpful?

Solution

The problem is that you're trying to set properties on the selectedPointStyle property, which is nil by default. In the same way that you created a new SChartPointStyle object for the pointStyle property, you need to create one for the selectedPointStyle property.

Update your code to the following and you should observe the selection effect that you're after:

- (SChartSeries*)sChart:(ShinobiChart *)chart seriesAtIndex:(NSInteger)index {
   SChartLineSeries* lineSeries = [[SChartLineSeries alloc] init];

   lineSeries.selectionMode = SChartSelectionPoint;

   SChartLineSeriesStyle *style = [SChartLineSeriesStyle new];
   style.pointStyle = [SChartPointStyle new];
   style.pointStyle.showPoints = YES;
   style.pointStyle.color = [UIColor whiteColor];
   style.pointStyle.radius = @(5);

   style.selectedPointStyle = [SChartPointStyle new];
   style.selectedPointStyle.showPoints = YES;
   style.selectedPointStyle.color = [UIColor orangeColor];
   style.selectedPointStyle.radius = @(15);

   [lineSeries setStyle:style];
   return lineSeries;
}

In answer to your other question, dashed lines are not currently supported as part of ShinobiCharts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top