cancel
Showing results for 
Search instead for 
Did you mean: 

Changing color of chart dynamically when temperature is out of range

pHi-Tech
7 - Data Storage
7 - Data Storage

Hi all,

I display a chart of different temperatures from devices, and I would like to display temperatures that are out of range with a different color (e.g. red).

1. I understood that conditional formatting can help here - but I cannot find or use this feature in my edit space in this chart. I don't know why.

2. Do I need to write a code? or I can use features to help me?

3. If I choose RED as my out of range color, how can I modify that in range temperature wont use the color RED.

Thank you!

  

2 REPLIES 2

DRay
Community Team Member
Community Team Member

Hi @pHi-Tech,

Thank you for reaching out. Are you able to use conditional formatting on other charts of the same type? I'm wondering if there is a permissions or ownership issue here.

If you can use conditional formatting that would be much easier than trying to write a script. 🙂

 

David Raynor (DRay)

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hi @pHi-Tech ,

I'll try answer your questions, but then provide some commentary below.

Sisense is very flexible - so the answer to 'can I do this' is almost always 'yes' - but the 'how can i do this' could have many different approaches.

1. I understood that conditional formatting can help here - but I cannot find or use this feature in my edit space in this chart. I don't know why.

This depends on the chart you are using. Can you share more information on this? 

2. Do I need to write a code? or I can use features to help me?

As above.

3. If I choose RED as my out of range color, how can I modify that in range temperature wont use the color RED.

If we're using the OOTB (out of the box) theme, then charts will cycle through the pallette on the dashboard (screenshot below). They'll cycle through these colours and then move down a gradient and start again to assign categories with colours.

rapidbisupport_1-1722559122746.png

If you're looking to use code to do this - an example widget script for a line chart:

const threshold = 3

// when the widget is processing the result it's recieved from Sisense (and before it puts the result in the chart we're about to render)
widget.on('processresult', (w, args) => {
  // lets iterate through the different categories
  for (let i = 0; i < args.result.series.length; i++) {
    // for the data points in each category
    const category = args.result.series[i]
    for (let j = 0; j < category.data.length; j++) {
      // if the 'datapoint' is greater than our threshold, let's change the color of the point
      const datum = category.data[j]
      if (datum.y > threshold) {
          datum.color = 'red'
      }
    }    
  }
})

 Will result in this.

rapidbisupport_0-1722559101955.png

There are ways to change the entire category line color if they ever went over a threshold, etc. so if you can get more specific about what you're trying to achieve, we can provide a more specific script.

Alternatively, feel free to take us up on our free 30-minute consult: https://www.rapidbi.com.au/sisense-add-ons/Services/Free-30-Minute-Sisense-Consultation/

 
Let me know how you go?