2

I'm trying to specify a color in a point with highlightStyle: 'halo', and tickmarksStyle: ['circle'] defined.

Graph:

enter image description here

I want to change the color of those points to red if they surpass that blue line. The condition is no big deal but can't seem to figure it out.

Or, if it's more simple, change the line segment color to red if the main line surpass the blue lines.

I'm been looking at the Line chart API but can't find a parameter that works with my scenario.

What can I do?

CaldeiraG
  • 152
  • 2
  • 14

1 Answers1

1

If I understand your request correctly then the easiest way would be to use the filledThreshold and filledThresholdColors properties.

Here's the code:

new RGraph.Line({
    id: 'cvs',
    data: [d1, d2],
    options: {
        backgroundGridHlinesCount: 5,
        backgroundGridVlines: false,
        backgroundGridBorder: false,
        axes: false,
        filled: true,
        filledRange: true,
        filledRangeThreshold: 12,
        filledRangeThresholdColors: ['red', 'blue'],
        xaxisLabels: ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'],
        colors: ['transparent', 'transparent'],
        xaxisTickmarksCount: 15,
        tickmarksStyle: null
    }
}).draw();
Richard
  • 4,809
  • 3
  • 27
  • 46
  • Thanks for the quick answer Richard! On your example it works but on mine it throws a alert saying: "You must have only two sets of data for a filled range chart" and some weird chart: https://i.stack.imgur.com/57p1v.png – CaldeiraG May 15 '19 at 14:39
  • Do you want me to send on a Pastebin what I've done? – CaldeiraG May 15 '19 at 14:39
  • Well how many datasets do you have? Send me a link to your code. – Richard May 15 '19 at 16:09
  • So, instead of having a array with my datasets, I need to have multiple line objects? – CaldeiraG May 17 '19 at 06:48
  • That's right. Though any further datasets can be added to the second Line chart object if they use the same scale. – Richard May 17 '19 at 11:10
  • Thanks Richard, i'll try to replicate the example on my case and I'll give some feedback soon. I really like RGraph and also know you're the author of it so keep up the good work ;) – CaldeiraG May 17 '19 at 11:39