高图:根据y值更改样条线颜色

时间:2019-11-03 21:13:21

标签: javascript highcharts

我的yAxis部分如下所示:

yAxis: {
                    title: {
                      text: 'Height of tide<br>in feet.'
                        },
                        gridLineColor: '#197F07',
                        gridLineWidth: 0,
                        lineWidth:1,
                        plotLines: [{
                            color: '#FF0000',
                            width: 1,
                            value: 0
                    }]
                },

如何将y = <0的线条颜色更改为红色?

1 个答案:

答案 0 :(得分:1)

您可以使用negativeColor属性更改颜色。 低于阈值的图形部分或点的颜色。默认阈值为0。

Highcharts.chart('container', {

  series: [{
    data: [-6.4, -5.2, -3.0, 0.2, 2.3, 5.5, 8.4, 8.3, 5.1, 0.9, -1.1, -4.0],
    negativeColor: '#FF0000'
  }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>

API参考:https://api.highcharts.com/highcharts/plotOptions.line.negativeColor