Reputation: 473
I need to create a line graph on iOS. The graph is a time series, with time along the X axis and a percentage value along the Y axis. I need to be able to set both the X and Y position of each sample, because the samples are not taken at a regular interval (ie. the X axis positions are arbitrary). I do not want to normalise the data to a fixed interval, because that will cause rounding and so on. I have tried Core Plot and JBChartView, but I cannot find any way to set the X positions in either of these libraries.
Is there any way to set the X axis position of each sample in these libraries? I've looked through all the protocols, but it's possible I've missed something.
If it is not possible to set the X axis position in either of those libraries, can you recommend a graphing library that has this functionality?
Thanks!
Upvotes: 1
Views: 1745
Reputation: 27381
Core Plot can absolutely do this. The scatterplot pulls data from its datasource independently for the x- and y-values. Most of the included examples just use the data index for the x-value, but that choice was only to make the examples easier to follow. The x-values can be anything. The examples that use a date scale on the x-axis are one demonstration of this feature. The plot values do not need to be evenly spaced; the data is a series of x-y pairs.
Upvotes: 1
Reputation: 603
Look at these Libraries
https://github.com/Boris-Em/BEMSimpleLineGraph
https://github.com/freshking/DynamicGraphView
Hopefully this will help
Upvotes: 2