Web Charts stopped working in 2023r2

I updated my Xojo version from 2022r4.1 to 2023r2 on Windows 10. After the update all of my web charts stopped working. I have tried a couple of things to get them to work but nothing has helped. Here is the code that I use to fill one of the charts. Does anyone have any suggestions?
I don’t get any error. The chart does not show the bars.

// get a data set.
var sql as string
var rs as rowset
Var data(6) As Double
sql = "select status, count(status) from DispatchEquip group by status"
try
  rs = session.db.SelectSQL(sql)
catch e as DatabaseException
  messagebox(e.message)
end try
if rs <> nil then
  if not rs.AfterLastRow then
    for each row as DatabaseRow in rs
      select case rs.columnat(0).StringValue
      case "Scheduled"
        data(0) = rs.columnat(1).DoubleValue
      case "Invoiced"
        data(1) = rs.columnat(1).DoubleValue
      case "Delivered"
        data(2) = rs.columnat(1).DoubleValue
      case "Delete"
        data(3) = rs.columnat(1).DoubleValue
      case "On Hold"
        data(4) = rs.columnat(1).DoubleValue
      end select
    next
  end if
  rs.close
end if
sql = "Select Count(1) From DispatchEquip Inner Join "_
+ "dispatchrequest On DispatchEquip.ticketdate = dispatchrequest.ticketdate Where dispatchrequest.submitted = ? And DispatchEquip.Status Is Null"
try
  rs = session.db.SelectSQL(sql, 1)
catch e as DatabaseException
  messagebox(e.message)
end try
if rs <> nil then
  if not rs.AfterLastRow then
    data(5) = rs.columnat(0).DoubleValue
  end if
  rs.close
end if


Var colors() As Color = Array(Color.Yellow, Color.green, Color.orange, Color.DarkGray, Color.Blue, Color.Purple)
var myset as new WebChartCircularDataset("Status Data", data, colors)
Chart1.HasAnimation = true
Chart1.AddDataset(mySet)

Chart1.AddLabels("Scheduled: " + data(0).ToString, "Invoiced: " + data(1).ToString, "Delivered: " + data(2).ToString, "Deleted: " + data(3).ToString, "On Hold: " + data(4).ToString, "UnAssigned: " + data(5).ToString)

Hi Gary, sorry about that :pray:. Can you please open a new case in Issues with a sample project?

It appears that WebChartCircularDataset no longer works for a barchart in 2023r2. I changed it to ChartLinearDataset and the bars now show up.
Is there a way to have a different color for each bar in the bar chart?
Thanks

I think, you should use ChartCircularDataset.

https://documentation.xojo.com/api/user_interface/charts/chartcirculardataset.html

Martin
Thanks for the suggestion. I did try ChartCircularDataset but it does not work for the Bar Chart.
Not sure why ChartLinearDataSet does not support different color bars. Unless I am missing something.
Thanks

Your code above uses WebChartCircularDataset. So I’m not wondering, why it don’t work for your Bar Chart.

Previous version allowed using CircularDataset to create BarCharts with each bar with different color.

Now, is not possible to use CircularDataset with BarCarts. All bars are same color.

1 Like

Sounds like Xojo is taking away a feature that previously worked. That is hard to explain to my paying customer. :angry:

Each dataset can have its own color:

Captura de pantalla 2023-08-17 a las 16.30.23

Var data() As Double
For i As Integer = 1 To 10
  data.Add(System.Random.Gaussian)
Next

Var ds1 As New ChartLinearDataset("Foo", Color.Red, True, data)
Var ds2 As New ChartLinearDataset("Bar", Color.Blue, True, data)

Me.AddDatasets(ds1, ds2)

Before, a single dataset allow to have each bar with a different color using WebChartCircularDataset

I have seen a couple of users that want each bar for a single dataset with a different color.

Edit: it looks like Gary used 6 colors for 6 different bars with a single dataset, right @Gary_Smith

I will try that. Thanks

@Ricardo_Cruz is there a way to do something like this?

Image from: https://www.chartjs.org/docs/latest/charts/bar.html

This is a single dataset with different colors for the bars.

1 Like

I don’t think so, no, but it doesn’t feels right to represent the same dataset with different colors. Even the label appears as red in that screenshot.

In any case, if your project really needs to represent that kind of charts, please open an Issue so we can track it and implement it.

Maybe there is a way to remove the red rectangle next to the label?

Of course is not ‘typical’ to have a bar chart like that for same data (like sales) for different months.

Bug Gary was using the colors for each bar to indicate that one bar is ‘Scheduled’, other ‘Invoiced’, ‘Delivered’, ‘Delete’, ‘On Hold’ and ‘UnAssigned’.

If Gary already used that colored chart to deliver something to a paying customer and now is not possible, then it is a problem.

Anyway, Chart.js can do it (as shown above) with the backgroundColor option for the dataset. I hope is not hard to add (if not already included).

2 Likes

I’m previous releases it was possible to use circular datasets to display Bar or Line charts, and linear datasets to display Pie or doughnuts charts, for example. That lead to all kind of little “bugs” here and there… since 2022 you need to use linear datasets to bars/line charts, and circular datasets to, well, pie, doughnut chart, etc.

I think that was updated in the Docs, plus the published blog posts and videos on our YouTube channel, including the session about Charts for the London XDC.

If you need to color each bar for your charts, you can use this WebSDK:

see the ‘Bar 2’ code to get this:
image

You have control over other things, like border width (you can set it to 0 if you don’t want the border):
image

and remove the red rectangle next to the label on top:
image

Note: the webSDK is using Chartjs 3.7.1 you may want to update to the latest version.

1 Like

I have the same problem… it don’t work on older browsers (or OS).
Charts don’t appears on Safari 11 On Mac OS High Sierra but works on Safari 16 on Mac OS Ventura and Safari 14 on Mojave.

That is not the same problem. I haven’t read the Chart.js requirement, maybe the new version dropped support for older browsers.

From the Xojo requirements:

Note

The latest supported versions of these browsers are recommended and in some cases may be required.

@AlbertoD Thank you for pointing me to this solution. I now have the color added back to the bars. Also removed the legend which removed the colored box, then added a Title and was able to make the font larger in the Title. My customer is happy now. Thanks

1 Like