[iOS] Which chart should I use for this?


#1

Hi.

I have several events (~15) which occur on Time x and ends on Time y and maybe again on Time a and Time b.
Now I need to show this events on a chart and I’m not sure which shinobi chartserie I have to use for this.

I attached an Image with an example of the chart I need to build.

Thx for your help.


#2

Hi.

I added all of my event data into an array of dictionaries. So every event with its on/off values is a single line series with two data points.

The Data array looks like this (where 0 is the start and 1 is the end value):

(
{
    event = 0;
    0 = "2014-05-15 09:14:00 +0000";
    1 = "2014-05-15 09:17:00 +0000";
},
{
    event = 15;
    0 = "2014-05-15 09:14:00 +0000";
    1 = "2014-05-15 10:20:00 +0000";
}
)

If someone is interesed here is the delegate code:

- (int)numberOfSeriesInSChart:(ShinobiChart *)chart {
    return [self.data count];
}

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

- (int)sChart:(ShinobiChart *)chart numberOfDataPointsForSeriesAtIndex:(int)seriesIndex {
    return 2;
}

- (id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex {
    NSDictionary *dict = self.data[seriesIndex];
    
    SChartDataPoint *datapoint = [[SChartDataPoint alloc] init];
    datapoint.xValue = dict[@(dataIndex)];
    datapoint.yValue = dict[@"event"];
    
    return datapoint;
}

So far that works for me. 

Cheers
Frank


#3

Thanks for sharing that. Seems like a nice neat solution!