Open eakteam opened 5 years ago
I just tried the library for the first time and it crashes every time:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.mikephil.charting.charts.LineChart
android:layout_width="match_parent"
android:id="@+id/chart"
android:layout_height="400dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
val entries = listOf(
Entry(22F, 40F),
Entry(21F, 32F),
Entry(20F, 34F)
)
val set = LineDataSet(entries, "label")
val data = LineData(set)
chart.data = data
chart.invalidate()
com.github.PhilJay:MPAndroidChart:v3.1.0-alpha
The issue is that generateTransformedValuesLine
calculates the count:
fnal int count = ((int) ((max - min) * phaseX) + 1) * 2;
However the count is negative (-2) because min=2
and max=0
calculated by BarLineScatterCandleBubbleRenderer#set
.
@PaulWoitaschek , do you find any solution for this ? It is really causing problems with Apps Stability. And Crash Rate have major impact on App visibility/ranking in the Play Store.
My solution is not not use this library 😉
As my first experience was a crash, I didn't want to include this in my app.
I found that my data was not ordered. So make sure to sort your data.
@kamalh16 yeah, this library uses the perfect behavior to improve one's extrasensory skills
@PaulWoitaschek , @kamalh16 , @dstd ... hmmm... I don't think that this is something that can't be solved and just say "don't use this lib".
This lib. is in fact very nice but there are some issues (this is normal) but should be fixed. Maybe they are not fixing as it should because promotion of SciChart to stay on top, but regardless of this, for everyone this is the best solution for open source. If you have any testing that solves this issue would be great to share with us. One way is to manually edit the library and add catch
methods in every place where the crashes are thrown, but better to solve it than to hide it if you understand what i mean with my low English(sorry for that).
Best Regards, hope that everything will be improved and solved in following ....
I don't say that anyone shouldn't be using this library, in fact it's fascinating to see such a complex and customizable library.
I'm just saying that if my very fist experiment with this library immediately crashes I simply have lost the trust.
@eakteam @PaulWoitaschek Completely agreed, specially with such a trivial error like this, the error logs should either state that you should order your data, or the library should implicitly order the data based on a default parameter, which you can change and customize.
@kamalh16 , @PaulWoitaschek yes you'r right i understand, but i have didn't found any way to fix and simplify this issue within the library itself (not in our code). And crashes or issues have direct impact on how the app is ranked in Google Play Store, so this is making very bad effect in my case (and everyone else who is experiencing same thing). I just mean that this should be fixed ASAP. @PhilJay , what do you think , it is really important for some of us
I faced the Same Issue. The problem was solved
What I was doing was as below : I was setting Labels For X- Exis.. ==>[ My data was Unsorted ]<== lets say [3.0, 3.1, 2.0, 4.5, 0.0] so long.....
// xAxisLabels = ArrayList()
// xAxisLabels.add("0")
// xAxisLabels.add("1")
// xAxisLabels.add("2")
// xAxisLabels.add("3")
// xAxisLabels.add("4")
// xAxisLabels.add("5")
First what solved the error Was sorting My Data, but that did not give the required results... i.e. Gives you Straight line or an ascending line. [No data Downward only upward since sorted]
The second solution was not sorting data, but removing custom labels from X-Axis. Also commenting code that sets values for X-Labels. like below
// chart!!.xAxis.setValueFormatter { value, _ ->
//
// return@setValueFormatter xAxisLabels[value.toInt()]
// }
Now I get UP and Down Line as is my data with a default step size one[1] auto-incremented.
for (i in 0 until yval.size-1) {
values.add(
Entry(i.toFloat(),
if(yval[i]<0){0f}else{yval[i]},
this@ProfileView.getDrawable(R.drawable.graph_drawable)
)
)
}
I hope It helps Someone.
I have more than 1K bug reports because of this issue. I have tried myself to modify and trying things but can't be solved. Does anyone know to fix this very old issue ???