Highcharts - 在特定y轴值处添加垂直线

时间:2015-07-21 09:01:12

标签: javascript highcharts

使用Highcharts,我试图在特定的Y轴值处添加垂直线(非水平线)。我不知道相应的x轴点/值。

请在以下链接中找到示例: specification of the "each()" function

var chart = new Highcharts.Chart({
chart: {
    renderTo: 'container',
    defaultSeriesType: 'column',
    borderWidth:1,
    borderColor:'#ccc',
    marginLeft:110,
    marginRight:50,
    backgroundColor:'#eee',
    plotBackgroundColor:'#fff',
    alignTicks:false,
},
title:{
    text:'Pareto Test 2'
},
legend:{

},
tooltip:{
    formatter:function(){
            if(this.series.name == 'Cumulative Percent'){
                return this.y + '%';
            }
            return this.y;
        }
},
plotOptions: {
    series: {
        shadow:false,
    }
},
xAxis:{
    categories:['A','B','C','D','E','F','G','H'],
    lineColor:'#999',
    lineWidth:1,
    tickColor:'#666',
    tickLength:3,
    title:{
        text:'X Axis Title',
        style:{
            color:'#000'
        }
    }
},
yAxis:[{
    endOnTick:false,
    lineColor:'#999',
    lineWidth:1,
    tickColor:'#666',
    tickWidth:1,
    tickLength:3,
    gridLineColor:'#ddd',
    title:{
        text:'Y Axis Title',
        rotation:0,
        margin:50,
        style:{
            color:'#000'
        }
    }
},{
    title:{text:''},
    gridLineWidth:0,
    lineColor:'#999',
    lineWidth:1,
    tickColor:'#666',
    tickWidth:1,
    tickLength:3,
    endOnTick:false,
    opposite:true,
    min:0,
    labels:{
        formatter:function(){
            return this.value + '%';
        }
    }
}],
series: [{
    name:'Values',
    yAxis:0,
    data: [515,475,360,255,245,230,120,115],
},{
    type:'line',
    name:'Cumulative Percent',
    yAxis:1,
    data: [28,46,60,73,84,91,96,100],
}]

});

在上面的示例中,我想添加一条垂直线,例如73%或84%的标记(或在线上任意y轴点)。我该怎么做?请帮我。

0 个答案:

没有答案