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

autoScaleMinMaxEnabled does not work with Candle Charts #986

Closed
rickkln opened this issue Apr 28, 2016 · 11 comments
Closed

autoScaleMinMaxEnabled does not work with Candle Charts #986

rickkln opened this issue Apr 28, 2016 · 11 comments

Comments

@rickkln
Copy link

rickkln commented Apr 28, 2016

Setting chartview.autoScaleMinMaxEnabled = true works as expected on my line charts. However on my candle chart the application crashes if autoScaleMinMaxEnabled is set to true.

The relevant part of the stacktrace is here:

#0  0x0170c11c in CandleChartDataSet.calcMinMax(start : Int, end : Int) -> () at /Users/dcg/Desktop/git/ios-charts/Charts/Classes/Data/Implementations/Standard/CandleChartDataSet.swift:48
#1  0x0170c158 in @objc CandleChartDataSet.calcMinMax(start : Int, end : Int) -> () ()
#2  0x016f714c in ChartData.calcMinMax(start : Int, end : Int) -> () at /Users/dcg/Desktop/git/ios-charts/Charts/Classes/Data/Implementations/Standard/ChartData.swift:167
#3  0x0176df90 in BarLineChartViewBase.calcMinMax() -> () at /Users/dcg/Desktop/git/ios-charts/Charts/Classes/Charts/BarLineChartViewBase.swift:320
#4  0x0176776c in CandleStickChartView.calcMinMax() -> () at /Users/dcg/Desktop/git/ios-charts/Charts/Classes/Charts/CandleStickChartView.swift:30
#5  0x0176d8d4 in BarLineChartViewBase.notifyDataSetChanged() -> () at /Users/dcg/Desktop/git/ios-charts/Charts/Classes/Charts/BarLineChartViewBase.swift:293
#6  0x0174dd58 in ChartViewBase.data.setter ()

Any ideas as to why this might be happening? Is the documentation wrong when it states that autoScaleMinMaxEnabled applies to candle charts too?

@rickkln rickkln changed the title autoScaleMinMaxEnabled does not work with Candle graphs autoScaleMinMaxEnabled does not work with Candle Charts Apr 28, 2016
@rickkln
Copy link
Author

rickkln commented Apr 29, 2016

On further investigation this ties in with this issue: #113

Essentially any graph that has autoScaleMinMaxEnabled = true and that contains xIndexes which don't have a matching yValue will cause the app to crash as soon as you zoom in.

@liuxuan30
Copy link
Member

can you fix and a PR?

@rickkln
Copy link
Author

rickkln commented May 3, 2016

Sorry I won't be able to put in the time for that as I have decided to switch to https://github.com/i-schuetz/SwiftCharts for now because of #194

@danielgindi
Copy link
Collaborator

You should not have nil yValues in your dataset. You should just omit them. If you have to skip x-index 5, then don't put an entry for it.

@rickkln
Copy link
Author

rickkln commented May 15, 2016

As far as I can see this should not be closed. To omit the values is not a valid approach due to the x-axis being a array of labels instead of proper data points. If you omit the values say for a depth chart (https://en.wikipedia.org/wiki/Market_depth, the bottom one in the example) with y values for volume versus x values for price then you end up with an incorrect chart. For example say you have entries at USD 100, 150, 201, 202, 203, 300. The spacing between those entries will be the equidistant if you simply enter those entries, which is incorrect. The space between 203 and 300 should not be the same as the space between 202 and 203. At this time the only way I have found to fix this is to generate x values for each amount from 100 to 300.

Any other suggestions are much appreciated.

@danielgindi
Copy link
Collaborator

You are talking about the x-indices. You can add x-indices as many as you'd like, without having to add y-values for them.

@rickkln
Copy link
Author

rickkln commented May 15, 2016

Well not with chartview.autoScaleMinMaxEnabled = true otherwise it crashes. As I said above:

Essentially any graph that has autoScaleMinMaxEnabled = true and that contains xIndexes which don't have a matching yValue will cause the app to crash as soon as you zoom in.

If you have x-indices without y-values for them and you set chartview.autoScaleMinMaxEnabled = true the app crashes with the stack-trace above as soon as you try and view the chart.

@rickkln
Copy link
Author

rickkln commented May 15, 2016

I think when it tries to calculate the factors by which to scale it tries to find the y for a given x and when there isn't one it crashes. I could be totally off though, I have only just started using your library.

@danielgindi
Copy link
Collaborator

I don't experience a crash. Do you have a piece of code to put in the Demo that will reproduce this?

@rickkln
Copy link
Author

rickkln commented May 15, 2016

Thanks for taking a look at it, it must be the combination of options I have that causes it. I have two line charts and one candle chart. Same setup function for all 3. The candle chart and one of the line charts experience the crash while the other does not, this makes me assume it is the data causing it. I don't have time to prepare a demo right now but I will do it next weekend. You can leave the issue closed for now.

@danielgindi
Copy link
Collaborator

I played with it with the combination you are describing - no crashes...
We'll wait for more info from you :-)

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