Page 1 of 1
Charts control not refreshing
Posted: Thu Oct 31, 2024 8:54 pm
by andyh1234
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?
Re: Charts control not refreshing
Posted: Thu Oct 31, 2024 9:58 pm
by Klaus
Hi Andy,
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
...
at least worth a try...
Best
Klaus
Re: Charts control not refreshing
Posted: Fri Nov 01, 2024 9:06 am
by bn
andyh1234 wrote: ↑Thu Oct 31, 2024 8:54 pm
Is there a way to force the widget to update?
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
That worked to update the otherwise not updated changes.
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
I even used only
Code: Select all
set the lockChartUpdates of widget "chart" to false
and it refreshed the chart widget.
Kind regards
Bernd
Re: Charts control not refreshing
Posted: Sat Nov 02, 2024 1:14 pm
by andyh1234
Thanks everyone,
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
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!
Re: Charts control not refreshing
Posted: Wed Nov 13, 2024 6:36 pm
by andyh1234
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?
Re: Charts control not refreshing
Posted: Wed Nov 13, 2024 6:47 pm
by andyh1234
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.
Re: Charts control not refreshing
Posted: Wed Nov 13, 2024 9:47 pm
by bn
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:
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
Just guessing.
Kind regards
Bernd
Re: Charts control not refreshing
Posted: Wed Nov 13, 2024 11:13 pm
by andyh1234
Ive just tried that in the simulator and it seems to work, you are a genius!
Thanks
Re: Charts control not refreshing
Posted: Thu Nov 14, 2024 10:40 am
by bn
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:
Code: Select all
on mouseUp
set the lockChartUpdates of widget "Chart View" to false
end mouseUp
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
Re: Charts control not refreshing
Posted: Thu Nov 14, 2024 1:15 pm
by andyh1234
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