Boris-Em / BEMSimpleLineGraph

Elegant Line Graphs for iOS. (Charting library)
MIT License
2.66k stars 382 forks source link

Unevenly spaced data #112

Closed matthewcheok closed 9 years ago

matthewcheok commented 9 years ago

I'm not sure if there's a solution for this - my data is unevenly spaced in the x-axis. I still want a continuous line through the points.

Boris-Em commented 9 years ago

Hi @matthewcheok, Could you please provide a screenshot? It seems extremely odd... Thanks!

matthewcheok commented 9 years ago

Sorry for the misunderstanding. It's more of a feature request I guess. I'm looking to plot unevenly spaced data.

mythodeia commented 9 years ago

@matthewcheok basically you want a scatter plot but having the dots connected with a line, right?

matthewcheok commented 9 years ago

Not quite... I have data in the form of prices and dates but the dates are not in regular intervals. I want a continuous trend line through the points.

Boris-Em commented 9 years ago

I see, this is an interesting feature. If you're familiar with the way BEMSimpleLineGraph works, what would you think is the best way to implement it?

matthewcheok commented 9 years ago

How about adding a datasource method like - (CGPoint)lineGraph:(BEMSimpleLineGraphView *)graph pointAtIndex:(NSInteger)index so I can specify both the x and y values?

This could be optional and take precedence over - (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index.

Boris-Em commented 9 years ago

Hi @matthewcheok, Would by any chance this issue and the issue #104 be the same?

A simpler way to implement it would maybe be that if you supply a null value for - (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index, the graph would skip this section and connect the previous and next dots together? (still respecting the X axis places).

matthewcheok commented 9 years ago

I guess the idea is similar. How would you specify a null value of type CGFloat?

nyssance commented 9 years ago

@matthewcheok If use Swift, you can return a nil or CGFloat by use CGFloat?

Sam-Spencer commented 9 years ago

PR #129 adds the ability to specify a NULL value. It is currently under review, but it looks like we'll be merging it here in the next few days.

Sam-Spencer commented 9 years ago

Pull Request #129 has been merged, and commit 16b1a40a32c81652ddeb0923d3121c8986ceb6f9 should add the requested feature.

Fine-tuned control and positioning is not, and likely will not be, supported by BEMSimpleLineGraph. The goal of the project is to remain lightweight and easy to use. Custom data point positioning would break a great deal of things in the project.

Thanks for the feature request! Glad to have found a solution. HUZZAH! :fireworks: