XY Chart displays blank (inconsistently) if I modify the data sources via script

If I modify the data sources of an XY chart in a script then it’s very inconsistent whether it will display correctly or not. More often than not the chart will be completely blank.

If I hard refresh the page it will usually make the data appear.

In the designer if I change a property of the XY chart (like title) it will force the data to appear. Though the designer seems to be more successful at displaying that data than the web in the first place.

Right now I have a hacky script that toggles the title property between ’ ’ and ‘’ for 4 seconds after any data change which has allowed me to get by for now.

Is there a proper workaround? Or am I possibly doing something wrong?

Here is the hacky placeholder solution binded to a timer property every second:

    # This title/wiggleTime logic is a workaround for when sometimes the chart
    # displays no data until a property is changed. The wiggle threshold exists
    # to ensure the data is binded before toggling the title. It does not toggle
    # endlessly because the chart starts to flicker if you do.
    if(system.date.isBefore(self.custom.wiggleTime, system.date.now())):
        return value
    if(self.view.custom.title == ' '):
        self.view.custom.title = ''
    else:
        self.view.custom.title = ' '