pandameister / chartjs-chart-radial-gauge

chartjs radial gauge chart implementation
MIT License
27 stars 12 forks source link

Change the color of the scale depending on external conditions. #11

Closed deviashin closed 4 years ago

deviashin commented 4 years ago

Hello!

There is a structure "if else" as a result of which should change the color of the scale.

Please, how to do this?

Should get something like this: var color;

if (condition) { color = "rgb(30, 148, 249)"; } else { color = "rgb(229, 73, 7)"; }

datasets: [ { data: [var], backgroundColor: 'color', } ]

pandameister commented 4 years ago

@deviashin sorry, i got busy didn't have time to take a look, did you work it out?

deviashin commented 4 years ago

Hello! No, unfortunately, I still need help. Under normal circumstances, this works, but in relation to your schedules - it just disappears. I can’t understand how to write code correctly Still need your help 😶

pandameister commented 4 years ago

@deviashin your code should work, if you change 'color' to be [color] in:

datasets: [ { data: [var], backgroundColor: [color], } ]

deviashin commented 4 years ago

Oh, those square brackets [ ] Thank you very much, now everything is fine!