-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
BarChart doesn't refresh after new dataSet #1590
Comments
your code seems fine. However, we need to know where it says |
You should be calling |
@petester42 it's called in data's setter, so don't have to call it again. unless the data is nil: /// The data for the chart
open var data: ChartData?
{
get
{
return _data
}
set
{
_data = newValue
_offsetsCalculated = false
if _data == nil
{
return
}
// calculate how many digits are needed
setupDefaultFormatter(min: _data!.getYMin(), max: _data!.getYMax())
for set in _data!.dataSets
{
if set.needsFormatter || set.valueFormatter === _defaultValueFormatter
{
set.valueFormatter = _defaultValueFormatter
}
}
// let the chart know there is new data
notifyDataSetChanged()
}
} |
Hmm true. I always just call reload. Makes everything easier. |
@ajimenezjulio there's no point in calling notifyDataChanged before setting data. It should happen after, and setting data calls it anyway. |
I have tried to update the data in my barChart, when i passed another dataSet which contains more data points everything goes well, but when i passed another dataSet with a lower data points, the app crashes.
I have also tried putting the barchartView.notifyDataSetChanged() after the line chart.DataSet.color but still crashes, maybe is the wrong place, but i have tried putting the notifyDataSetChanged in many places.
I let you my code, what i do when change the dataSet values is just calling the setChart method and pass the new values array as parameter.
The console shows "fatal error: index out of range".
Hope someone can help, thanks.
The text was updated successfully, but these errors were encountered: