听起来你非常正确。您需要一个多值系列(由适当的数据源方法提供):
- (SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(int)index
{
SChartCandleStickSeries *series = [SChartCandlestickSeries new];
series.crosshairEnabled = YES;
return series;
}
然后图表需要将工具提示设置为您提到的类型的实例(SChartCrosshairMultiValueTooltip
):
ShinobiChart *chart = [[ShinobiChart alloc] initWithFrame:self.view.bounds
withPrimaryXAxisType:SChartAxisTypeNumber
withPrimaryYAxisType:SChartAxisTypeNumber];
chart.datasource = self;
[self.view addSubview:chart];
chart.delegate = self;
chart.crosshair.tooltip = [SChartCrosshairMultiValueTooltip new];
为了完整起见,以下是数据源的数据点方法:
- (id<SChartData>)sChart:(ShinobiChart *)chart
dataPointAtIndex:(int)dataIndex
forSeriesAtIndex:(int)seriesIndex
{
SChartMultiYDataPoint *d = [SChartMultiYDataPoint new];
d.xValue = @(dataIndex);
[d.yValues setValue:_data[dataIndex] forKey:SChartCandlestickKeyOpen];
[d.yValues setValue:@([_data[dataIndex] doubleValue] * 1.3) forKey:SChartCandlestickKeyHigh];
[d.yValues setValue:@([_data[dataIndex] doubleValue] * 0.8) forKey:SChartCandlestickKeyLow];
[d.yValues setValue:@([_data[dataIndex] doubleValue] * 1.1) forKey:SChartCandlestickKeyClose];
return d;
}
(注意这里的值只是样本)