1

我有一个 SCHartLineSeries,当我选择一个点时, selectedPointStyle 似乎没有得到应用。

这是我的代码:

-(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];
}

请帮忙。我们正处于关键时刻。另外,如果我必须自定义以显示虚线,是否可以在 Shinobi 中这样做?

4

1 回答 1

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.

于 2013-12-10T20:50:23.640 回答