Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XGrid not in sync for identical x values but different chart types #99

Closed
AlBirdie opened this issue May 22, 2015 · 13 comments
Closed

XGrid not in sync for identical x values but different chart types #99

AlBirdie opened this issue May 22, 2015 · 13 comments
Labels

Comments

@AlBirdie
Copy link
Contributor

Take two charts, vertically stacked in a UIView.
Make one chart a BarChart, the other one a LineChart and feed them with the exact same data.
Once you zoom in, you'll notice that after a certain point, the x grid lines start to spread.

In order to mitigate this issue, I've created some 'ghost' (clearColored) BarDataSets for all my charts that show LineData only (all of my charts are CombinedCharts, but that doesn't really matter here as the issue is present with single type charts as well), so that the x grid stays in sync, which it does in case all charts show the same type at once (in my case, CombinedData with a 'ghost' BarDataSet on all charts).

Now, that workaround wouldn't necessarily be an issue, but given that more DataSets cause more load on the CPU, hence slower performance of the library, I'd like to avoid such trickery if possible. Not having to render an extra set for each chart would heavily speed up our chart on slower devices such as the iPhone4S or the iPad2/3.

@danielgindi
Copy link
Collaborator

I think I saw a similar issue open in the android repo...
Anyway if a combined chart shows its charts in sync then I do not see a
reason it won't be synced for multiple charts?..

‏בתאריך יום שישי, 22 במאי 2015, AlBirdie notifications@github.com כתב:

Take two charts, vertically stacked in a UIView.
Make one chart a BarChart, the other one a LineChart and feed them with
the exact same data.
Once you zoom in, you'll notice that after a certain point, the x grid
lines start to spread.

In order to mitigate this issue, I've created some 'ghost' (clearColored)
BarDataSets for all my charts that show LineData only (all of my charts are
CombinedCharts, but that doesn't really matter here as the issue is present
with single type charts as well), so that the x grid stays in sync, which
it does in case all charts show the same type at once (in my case,
CombinedData with a 'ghost' BarDataSet on all charts).

Now, that workaround wouldn't necessarily be an issue, but given that more
DataSets cause more load on the CPU, hence slower performance of the
library, I'd like to avoid such trickery if possible. Not having to render
an extra set for each chart would heavily speed up our chart on slower
devices such as the iPhone4S or the iPad2/3.


Reply to this email directly or view it on GitHub
#99.

@AlBirdie
Copy link
Contributor Author

Well, a CombinedChart by itself has only one xAxis. The issue comes into play when you've got several CombinedCharts in a single UIView positioned below each other. In that scenario the x axes of those two CombinedCharts are only in sync when you actually have identical chart types in both CombinedCharts.

@danielgindi
Copy link
Collaborator

Can you make a screenshot?

@AlBirdie
Copy link
Contributor Author

bildschirmfoto 2015-05-26 um 18 41 38

Sure. Top chart is a combined chart with LineData and CandleStickData, Volume is a CombinedChart with BarData and LineData, rate of change (ROC) is a CombinedChart with LineData only, and the MACD is again BarData and LineData.

I've explicitly removed the BarData from the (ROC) to demonstrate the issue. Add the BarData again and everything's in sync again.

Note that all charts share the exact same x data values.

@danielgindi
Copy link
Collaborator

Oh now I get you... it really is weird... @phil any ideas?

@phil
Copy link

phil commented May 27, 2015

That is weird, but then I haven't seen this project yet … which is unfortunate as I've been hand rolling my candlestick charts!

@danielgindi
Copy link
Collaborator

Does this still happen?

@AlBirdie
Copy link
Contributor Author

I'm gonna check with the latest version first thing tomorrow morning.

@AlBirdie
Copy link
Contributor Author

Looks good thus far! Excellent!

@danielgindi
Copy link
Collaborator

:)

@AlBirdie
Copy link
Contributor Author

On further inspection it shows that this only works if 'setStartAtZeroEnabled = YES'. If you disable this, and add nil values to a dataSet (meaning you just omit certain values), the grid still runs out of sync.

@liuxuan30
Copy link
Member

@AlBirdie I guess it's not guarenteed what would happen if you add nil to your dataSet? If want omit, just not add at specific xIndex

@AlBirdie
Copy link
Contributor Author

With omitting I mean not adding them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants