Chart background highlight in HighChart

社会主义新天地 提交于 2019-12-11 21:54:13

问题


In this question it's explained how to set the background to have two colours (zebra like). My need is to highlight in the chart temporal changes via setting accordingly the background colour, like this:

the two blue area may identify periods where something was happening and the white one when it wasn't. On top of this I'll then add lines and other charts.

Can this be done via passing Highchart with start and end date of periods to be highlighted? (an area chart workaround maybe?)


回答1:


What you most likely need is plotBands

xAxis.plotBands

A colored band stretching across the plot area marking an interval on the axis.

In a gauge, a plot band on the Y axis (value axis) will stretch along the perimiter of the gauge.

plotBands can be added on either of the axes, in your case you seem to want it on the xAxis, following is how one could do it

xAxis: {
    plotBands: [{ 
        color: '#FCFFC5',
        from: Date.UTC(2010, 0, 2),
        to: Date.UTC(2010, 0, 4)
    }]     
}

Plotbands @ jsFiddle



来源:https://stackoverflow.com/questions/19186249/chart-background-highlight-in-highchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!