Highcharts 能够为打印的日期段应用彩色区域

Highcharts 能够为打印的日期段应用彩色区域,highcharts,highstock,Highcharts,Highstock,在这个例子中。我想为打印/选定的日期段应用彩色区域。例如,如果我选择点1到10,这些点的背景应该高亮显示 var $report = $('#report'); // create the chart var chart = new Highcharts.Chart({ chart: { renderTo: 'container', events: { selection: function(event) { if (event.xAxi

在这个例子中。我想为打印/选定的日期段应用彩色区域。例如,如果我选择点1到10,这些点的背景应该高亮显示

var $report = $('#report');

// create the chart
var chart = new Highcharts.Chart({
chart: {
    renderTo: 'container',
    events: {
        selection: function(event) {
            if (event.xAxis) {
                var min = Math.ceil( event.xAxis[0].min ),
                    max = Math.ceil( event.xAxis[0].max ),
                    data = this.series[0].data,
                    list = [];

                $('#report').empty();

                for(i=min; i<max; i++)
                    list.push('<li>x: '+data[i].x+', y: '+data[i].y+'</li>');

                $('#report').append( list.join('') );

            }
            return false;
        }
    },
    zoomType: 'x'
},
xAxis: {
},

series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6,     54.4]        
}]
});
var$report=$(“#report”);
//创建图表
var图表=新的Highcharts.图表({
图表:{
renderTo:'容器',
活动:{
选择:功能(事件){
if(event.xAxis){
var min=Math.ceil(event.xAxis[0].min),
max=Math.ceil(event.xAxis[0].max),
data=此.series[0]。数据,
列表=[];
$(“#报告”).empty();

对于(i=min;i您只需在
选择
事件中添加
PlotBand

 chart.xAxis[0].removePlotBand('plot-band-1');
                chart.xAxis[0].addPlotBand({
                    from: min,
                    to: max,
                    color: '#FCFFC5',
                    id: 'plot-band-1'
                });
示例供您参考

希望这有帮助