question

Kalpana-3650 avatar image
0 Votes"
Kalpana-3650 asked YijingSun-MSFT commented

Help with ChartJS in web forms -Custom Ticks in y axis values

Hi

I have 2 y axis on my chart. I need the right side of the y axis to have custom values such as ( 2000, 4000, 5000, 55000)

I am trying to replicate an example from this site, https://jsfiddle.net/9a0cfae0/3/

But I am not getting those scales. Here is the script.

I need help with the y1 axes.
101800-barchartajax.txt


dotnet-aspnet-general
barchartajax.txt (9.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered YijingSun-MSFT commented

Hi @Kalpana-3650 ,
As far as I think,you have wrong with the format of two yaxis. You need do like this:

     scales: {
                 yAxes: [{
                             id: 'y',
                             type: 'linear',
                             position: 'left',
                             beginAtZero: true,
                         }, {
                             id: 'y1',
                             type: 'linear',
                             position: 'right',
                             ticks: {
                                 max: 10000000,
                                 min: 0
                             }
                         }]
                }

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Yijing Sun

I am using chartjs v3. So, thats how I configured the scales - https://www.chartjs.org/docs/3.3.2/samples/scales/linear-min-max.html.

0 Votes 0 ·

Hi @Kalpana-3650 ,
I have tried your codes,I found may y1 axis [{}] format wrong.
Just like this:
102345-test-2.txt

Best regards,
Yijing Sun


0 Votes 0 ·
test-2.txt (2.1 KiB)