Charts control not refreshing

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Charts control not refreshing

Post by andyh1234 » Thu Oct 31, 2024 8:54 pm

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?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Charts control not refreshing

Post by Klaus » Thu Oct 31, 2024 9:58 pm

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... :D

Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Charts control not refreshing

Post by bn » Fri Nov 01, 2024 9:06 am

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

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Charts control not refreshing

Post by andyh1234 » Sat Nov 02, 2024 1:14 pm

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!

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Charts control not refreshing

Post by andyh1234 » Wed Nov 13, 2024 6:36 pm

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?

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Charts control not refreshing

Post by andyh1234 » Wed Nov 13, 2024 6:47 pm

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.
Attachments
chart.livecode.zip
(2.31 KiB) Downloaded 449 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Charts control not refreshing

Post by bn » Wed Nov 13, 2024 9:47 pm

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

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Charts control not refreshing

Post by andyh1234 » Wed Nov 13, 2024 11:13 pm

Ive just tried that in the simulator and it seems to work, you are a genius!

Thanks

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Charts control not refreshing

Post by bn » Thu Nov 14, 2024 10:40 am

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

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Charts control not refreshing

Post by andyh1234 » Thu Nov 14, 2024 1:15 pm

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

Post Reply