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

Show only 2 labels on xAxis in CombinedChartView #2670

Closed
seboslaw opened this issue Aug 2, 2017 · 1 comment
Closed

Show only 2 labels on xAxis in CombinedChartView #2670

seboslaw opened this issue Aug 2, 2017 · 1 comment

Comments

@seboslaw
Copy link

seboslaw commented Aug 2, 2017

Hey guys,

I'm displaying a dataset of ~300 double/date data pairs. Because I wanted to highlight the maximum value and the minimum value in that range I used a CombinedChartView (LineChart for the 300 values, and ScatterChart for the 2 max/min values).
What I'd like to accomplish now is to get only the 2 date strings of the max/min values displayed on the xAxis (as labels like "2015-05-03" below the left max value and "2016-04-22" below the right min value).
Is there a way to tell the CombinedChartView to only use the data from the ScatterChart for the labels on the x-Axis? Then it would only display the 2 min/max value labels.

What I've tried so far is to implement a custom IAxisValueFormatter and then only return a date String if stringForValue gets hit with either my min or my max value (otherwise just return "").
But for some reason stringForValue only gets called with 5 unique values - I guess the width estimation figured there's only room for 5 labels on the screen? And those 5 values don't contain my min/max values -> so no label is displayed at all.
screenshot 2017-08-02 21 37 41

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 3, 2017

If I were you, I'd like to override x axis to only generate the min/max values and display it.
override computeAxisValues(min: Double, max: Double) and feed axis.entries only the x point of you min/max value
You might need to add more parameters or create sub axis class though.. axis class does not hold chart data. It only knows the range and intervals.

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

No branches or pull requests

2 participants