Charts control not refreshing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Charts control not refreshing
This is a basic level issue Im getting with Livecode 10 and the basic chart widget.
Im passing data to it as
set the csvData of widget "chart" to "1,1" & cr & "2,1"
but the chart is not updating, sometimes it does, sometimes it does not, totally random behaviour.
Is there a way to force the widget to update?
Im passing data to it as
set the csvData of widget "chart" to "1,1" & cr & "2,1"
but the chart is not updating, sometimes it does, sometimes it does not, totally random behaviour.
Is there a way to force the widget to update?
Re: Charts control not refreshing
Hi Andy,
I would try to add something like:
at least worth a try...
Best
Klaus
I would try to add something like:
Code: Select all
...
lock screen
set the csvData of widget "chart" to EMPTY
set the csvData of widget "chart" to "1,1" & cr & "2,1"
unlock screen
...

Best
Klaus
Re: Charts control not refreshing
I also noticed that when I change values for the chart widget some values are not updated.
I made a button with this script:
Code: Select all
on mouseUp
set the lockChartUpdates of widget "chart" to true
set the lockChartUpdates of widget "chart" to false
end mouseUp
I suggest that you wrap your code to change the chart widget with these two lines.
Code: Select all
on mouseUp
set the lockChartUpdates of widget "chart" to true
-- your code
set the lockChartUpdates of widget "chart" to false
end mouseUp
Code: Select all
set the lockChartUpdates of widget "chart" to false
Kind regards
Bernd
Re: Charts control not refreshing
Thanks everyone,
I think I have a solution that works, putting together the help from here and a bit of guesswork
Setting the JSONdata property seems to force the chart to refresh where csvdata does not always do it, but csvdata does pass the data.
Anyway, this problem solved, onto the next one!
I think I have a solution that works, putting together the help from here and a bit of guesswork
Code: Select all
set the lockChartUpdates of widget "chart" to true
set the csvData of widget "chart" to "1,1"
get the chartJSONData of widget "Chart" of card "maincard" of stack "mainstack"
put it into tResult
set the chartJSONData of widget "Chart" of card "maincard" of stack "mainstack" to tResult
set the lockChartUpdates of widget "chart" to false
Anyway, this problem solved, onto the next one!
Re: Charts control not refreshing
I spoke too soon, it is still not working.
When I pass new data to the chart it does not immediately refresh. It will only refresh when I go to another card and then back to the first card, then the chart will refresh.
Is there a way in code to force the app to go to another card and back again, I have tried the obvious go to card but that did not force a refresh. Any other ideas?
When I pass new data to the chart it does not immediately refresh. It will only refresh when I go to another card and then back to the first card, then the chart will refresh.
Is there a way in code to force the app to go to another card and back again, I have tried the obvious go to card but that did not force a refresh. Any other ideas?
Re: Charts control not refreshing
Ive created a small test stack to show the issue.
Click the button to populate the chart with random data.
It works in Livecode IDE, but run it in the iOS simulator and you will get nothing, the chart does not refresh.
Click the button to populate the chart with random data.
It works in Livecode IDE, but run it in the iOS simulator and you will get nothing, the chart does not refresh.
- Attachments
-
- chart.livecode.zip
- (2.31 KiB) Downloaded 448 times
Re: Charts control not refreshing
Hi Andy,
Unfortunately I can not test on a simulator. But maybe you could try something that does force a refresh:
In a button of the card:
Just guessing.
Kind regards
Bernd
Unfortunately I can not test on a simulator. But maybe you could try something that does force a refresh:
In a button of the card:
Code: Select all
on mouseUp
local tOldRect, tNewRect
lock screen
put the rect of widget "Chart View" into tOldRect
put tOldRect into tNewRect
subtract 1 from item 3 of tNewRect
set the rect of widget "Chart View" to tNewRect
set the rect of widget "Chart View" to tOldRect
unlock screen
end mouseUp
Kind regards
Bernd
Re: Charts control not refreshing
Ive just tried that in the simulator and it seems to work, you are a genius!
Thanks
Thanks
Re: Charts control not refreshing
Hi Andy,
Glad it works for you.
I noticed that if e.g. for a line chart for the inspector I try to change the pointradius of a point it does not refresh the diameter. That leads me to believe that the chart widget does have issues with refreshing.
This happens when I had changed some other properties of the chart widget, not when first dragged from the tool bar.
If I either do the "resize code" or simply from a button this code:
the radius refreshes.
Could you please try above handler to try to refresh the chart widget in the simulator. It would be easier to handle.
Kind regards
Bernd
Glad it works for you.
I noticed that if e.g. for a line chart for the inspector I try to change the pointradius of a point it does not refresh the diameter. That leads me to believe that the chart widget does have issues with refreshing.
This happens when I had changed some other properties of the chart widget, not when first dragged from the tool bar.
If I either do the "resize code" or simply from a button this code:
Code: Select all
on mouseUp
set the lockChartUpdates of widget "Chart View" to false
end mouseUp
Could you please try above handler to try to refresh the chart widget in the simulator. It would be easier to handle.
Kind regards
Bernd
Re: Charts control not refreshing
Thanks
I've tried that and it has no effect in the iOS simulator which is a shame, but the resize code seems to work so that is a temporary fix.
Thanks
I've tried that and it has no effect in the iOS simulator which is a shame, but the resize code seems to work so that is a temporary fix.
Thanks