1

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?

Geeky Gal
  • 15
  • 5

1 Answers1

3

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.

sammyd
  • 883
  • 5
  • 6
  • That worked beautifully, thanks so much. Another question, I have two line series and how do I make points on both series selected at the same time? Basically, my chart has 2 y values sharing the same x value and I'm representing them as two series. I want to display both points as selected for a given X Value. – Geeky Gal Dec 11 '13 at 15:58
  • That's great. You should post your 2nd question as a new question so that it's easier for other people to find in future. And if you accept this answer then others will realise that it works :) – sammyd Dec 13 '13 at 14:11
  • I was doing exactly the same thing as you suggested Sam. The problem it wasn't working because the selected point style is nil by default and needed to be initialized. – Geeky Gal Dec 13 '13 at 16:38