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

How to set labels based on max and min value of the plot? #2434

Closed
klemenzagar91 opened this issue May 12, 2017 · 4 comments
Closed

How to set labels based on max and min value of the plot? #2434

klemenzagar91 opened this issue May 12, 2017 · 4 comments

Comments

@klemenzagar91
Copy link

Im using Charts - 3.0.2 to plot line graph. On the left side I want to have 3 labels. Min, max and one in the middle of the graph.

screen shot 2017-05-12 at 13 29 45

I set the granulation based on the min and max value:
graphView.leftAxis.granularity = (data.yMax - data.yMin)/2.0
So the spacing is now correct, but the problem still left with the grid offset. Because it starts drawing at 0.0 but I want it to start a the minimum value of the graph.

Is it possible? Do you know any workaround?

@liuxuan30
Copy link
Member

Sounds like you need ChartLimitLine and just make the limit line clear

@klemenzagar91
Copy link
Author

klemenzagar91 commented May 15, 2017

screen shot 2017-05-15 at 11 14 52

ok, but in that case, the label to the line cannot be placed on the left side of the axis, where other labels are. without this, I cannot limit lines.

Is there an option to use limit lines and show the labels in the position where other axis values are? I couldn't find it.

@thierryH91200
Copy link
Contributor

try that
for me it's ok

leftAxis.axisMinimum = min
leftAxis.axisMaximum = max
leftAxis.granularity = (max - min)/2
leftAxis.labelCount = 3
leftAxis.forceLabelsEnabled = true

@klemenzagar91
Copy link
Author

klemenzagar91 commented May 15, 2017

Ok, but in this case some parts of chart are cut off.
screen shot 2017-05-15 at 12 15 00
For this reason I have a 1% margin around the graph values:

let space = (data.yMax - data.yMin)*0.05
graphView.leftAxis.axisMaximum = data.yMax + space
graphView.leftAxis.axisMinimum = data.yMin - space

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

3 participants