Perspective XYChart Scripting - dataSources and series issue

I have a script that sets the dataSources and series props on an XYChart based on dropdown selections. I'm calling the script via a Property Change Script on a dropdown value property. The generation script runs several named queries and creates dicts that get assigned to the dataSources and series values on the chart.

Sometimes this works and the chart displays, but sometimes I get "No series properly configured." on the chart component, and this error in the console:

16:43:57.071 [Browser Thread: c0dbb329-5bde-48c5-8dc6-ebfd1c87c96e] ERROR Perspective.Designer.Workspace - level: LEVEL_ERROR
message: "components.XYChart: No series configured."
line_number: 2
source: "https://spbkyigapp01:8043/res/perspective/js/PerspectiveClient.ef24a2d510d2934354db.js"

This happens both in the designer and in the browser. In the designer the property values look fine. There are no property bindings on the chart itself, but this still seems like a timing issue. If I toggle preview mode off and on again, the chart fixes itself.

What could be causing this, and is there a workaround?

I've fought with this same issue a lot. What version are you using? I believe there was a fix for this in 8.1.26ish?

Prior to this version, this is what I ended up doing. Custom property in the root for dataSource and Series. Then binding to that custom property on dataSource and your series to the dataSource. I have a script transform on my series that then does a refreshBinding() on the datasource.