I am using the following method to change the scales on the left side of the a Web Chart to display the scale in percentage with the % sign. This method is called using Xojo.Core.Timer.Calllater. The function is called but the scale does not get formatted on the chart. This was working fine in 2022r.4.1
var exec() as String
exec.Add( "var chartObj = XojoWeb.getNamedControl('" + Chart4.ControlID + "').mChartObj;" )
exec.Add( "chartObj.options.scales.yAxes[0].ticks.callback = function(value, index, values) {" )
exec.Add( " return value.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:0});" )
exec.Add( "};" )
exec.Add( "chartObj.update();" )
ExecuteJavaScript( String.FromArray( exec, "" ) )
AlbertoD
(AlbertoD)
August 17, 2023, 7:12pm
2
With R2 the Chart component was updated. Some properties changed name (for example, I think, yAxes).
You will need to update the code to match what the new Chart.js version uses.
2 Likes
Thanks Alberto. With your suggestion, I have changed the method and it now works. See below for the updated code.
var exec() as String
exec.Add( "var chartObj = XojoWeb.getNamedControl('" + Chart4.ControlID + "').mChartObj;" )
exec.Add( "chartObj.options.scales.y.ticks.callback = function(value, index, values) {" )
exec.Add( " return value.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:0});" )
exec.Add( "};" )
exec.Add( "chartObj.update();" )
ExecuteJavaScript( String.FromArray( exec, "" ) )
2 Likes