WebChart override options

How do you set the y min and max on a webchart?

I tried this in the overrideoptions event

options.value(“min”)= -10
options.value(“max”)=100

Nothing changes on the graph it scales according to the data.

Any help would be appreciated.

You can use this code in the overrideoptions event:

Var injectionValue As New jsonItem
Var injectionTicks As New jsonItem
Var injectionyAxes As New jsonItem
Var injectionScales As New jsonItem

injectionValue.value("min") = -10
injectionValue.value("max") = 100
injectionValue.value("stepSize") = 10
injectionTicks.value("ticks") = injectionValue
injectionyAxes.add injectionTicks
injectionScales.value("yAxes") = injectionyAxes

options.value("scales") = injectionScales

Code based on this information:

thanks to @Jeannot_Muller

1 Like

Before looking at @Jeannot_Muller post I was trying to “make-it-work” as I usually do when I try to learn something, I was using “y” to “inject” the JSONItem with the “min” “max” values.

After reading Chartjs docs and release notes I see that a lot changed from Chartjs version 2 (don’t know exactly which version Xojo is using) and version 3.

“y” is used for Chartjs version 3
“yAxes” is used for Charjs version 2

If you want to use Xojo’s version you need to read older Chartjs documents, for example:
Chartjs docs 2.9.4

Can @Ricardo_Cruz confirm if Xojo is using Chartjs 2.9.4 or a different version?

1 Like

@Greg_O should be able to answer too :wink:

1 Like

Xojo uses Chart.js v2.9.3

You can check the version by inspecting the library after it’s loaded on the page. The version and license header is in tact.

3 Likes

AlbertoD

Thanks for the information.

1 Like