Conditional Chart Color Based on Value

Hello,

Does anyone know if itโ€™s possible to use a formula for the chart color.

Basically if the value is negative, I want the color to be red. Green if positive.

0 15 8,252
  • UX
15 REPLIES 15

did you try using โ€˜Format Rulesโ€™?

Steve
Platinum 4
Platinum 4

It doesnโ€™t seem like this applies to charts though.

Iโ€™d like to get the color of the bar to change based on the value.

Oh, right. Iโ€™m not aware of a way to do what you want. Maybe @Aleksi does?

Unfortunately thatโ€™s trueโ€ฆ itโ€™s not possible at this moment. If you want to do that, you need to use other services where you can generate the chart through the URL and add that as an image to your app.

Is that using a webhook? I didnโ€™t know that was possible.

For example this formula generates the URL and because itโ€™s an image column, it will show it in the app.

CONCATENATE(โ€œhttps://quickchart.io/chart?c=
{
type:โ€˜barโ€™,
options: {
plugins: {
legend: false}},
data:{
labels: [โ€˜0801โ€™,โ€˜0802โ€™,โ€˜0803โ€™,โ€˜0804โ€™,โ€˜0805โ€™,โ€˜0806โ€™,โ€˜0807โ€™,โ€˜0808โ€™,โ€˜0809โ€™,โ€˜0810โ€™,โ€˜0811โ€™,โ€˜0812โ€™,โ€˜0813โ€™,โ€˜0814โ€™,โ€˜0815โ€™,โ€˜0816โ€™],
datasets:[{
data:[34,28,11,29,41,8,29,14,11,23,31,25,11,7,28,31],
backgroundColor:โ€˜redโ€™
}]
},
options:{
scales:{
xAxes:[{
barThickness:20,
}]
}
}
}โ€)

Thanks! Iโ€™ll try this.

Hey Aleksi,

Iโ€™m running into trouble setting this up using multiple columns. Itโ€™s displaying โ€œChart Error: unexpected identifier - 1:154โ€

Can you tell what iโ€™m doing wrong?
CONCATENATE(โ€œhttps://quickchart.io/chart?c=
{
type:โ€˜barโ€™,
options: {
plugins: {
legend: false}},
data:{
labels: [โ€˜0โ€™,โ€˜1โ€™,โ€˜2โ€™,'3โ€™,โ€˜4โ€™,โ€˜5โ€™,โ€˜6โ€™,โ€˜7โ€™,โ€˜8โ€™,โ€˜9โ€™,โ€˜10โ€™,โ€˜11โ€™,โ€˜12โ€™,โ€˜13โ€™,โ€˜14โ€™,โ€˜15โ€™],
datasets:[{
data:{[Year 1],[Year 2],[Year 3],[Year 4],[Year 5],[Year 6],[Year 7],[Year 8],[Year 9],[Year 10],[Year 11],[Year 12],[Year 13],[Year 14],[Year 15]},
backgroundColor:โ€˜redโ€™
}]
},
options:{
scales:{
xAxes:[{
barThickness:20,
}]
}
}
}โ€)

Youโ€™re welcome

You need to make data an array so replace data:{โ€ฆ} by data:[โ€ฆ]

I tried it like this and it didnโ€™t work. also tried removing the {} for datasets as well and it did nothing. I havenโ€™t messed with these much so iโ€™m not sure what I could be doing wrong.

CONCATENATE(โ€œhttps://quickchart.io/chart?c=
{
type:โ€˜barโ€™,
options: {
plugins: {
legend: false}},
data:{
labels: [โ€˜0โ€™,โ€˜1โ€™,โ€˜2โ€™,'3โ€™,โ€˜4โ€™,โ€˜5โ€™,โ€˜6โ€™,โ€˜7โ€™,โ€˜8โ€™,โ€˜9โ€™,โ€˜10โ€™,โ€˜11โ€™,โ€˜12โ€™,โ€˜13โ€™,โ€˜14โ€™,โ€˜15โ€™],
datasets:[{
data:[[Year 1],[Year 2],[Year 3],[Year 4],[Year 5],[Year 6],[Year 7],[Year 8],[Year 9],[Year 10],[Year 11],[Year 12],[Year 13],[Year 14],[Year 15]],
backgroundColor:โ€˜redโ€™
}]
},
options:{
scales:{
xAxes:[{
barThickness:20,
}]
}
}
}โ€)

Try withโ€ฆ
data:["&[Year 1]&","&[Year 2]&"],

That worked great, thanks a lot!

Youโ€™re welcome

Top Labels in this Space