RGraph 折线图上特定点的不同颜色

Different color on specific point on RGraph line chart

我正在尝试在定义了 highlightStyle: 'halo',tickmarksStyle: ['circle'] 的点中指定颜色。

图表:

如果这些点超过那条蓝线,我想将它们的颜色更改为红色。条件没什么大不了的,但似乎无法弄清楚。

或者,如果更简单,如果主线超过蓝色线,则将线段颜色更改为红色。

我一直在查看 Line chart API 但找不到适合我的场景的参数。

我能做什么?

如果我正确理解您的请求,那么最简单的方法是使用 filledThresholdfilledThresholdColors 属性。

代码如下:

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();