x轴上的Highcharts虚线未完全穿过

时间:2018-12-26 17:23:17

标签: javascript d3.js highcharts line

我有这个图表的jsfiddle,我希望虚线从0到10一直遍历整个图形,我在另一个名为scatter的图形上进行了尝试,并且我希望它可以在type列上运行图形。我该怎么做呢? highcharts api中有我缺少的东西吗?

Access token generation

Highcharts.chart('container', {
chart: {
    type: 'column',
renderTo:'#container'
},
title: {
    text: ''
},
xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
    min: 0,
    title: {
        text: 'Total fruit consumption'
    },
    stackLabels: {
        enabled: true,
        style: {
            fontWeight: 'bold',
            color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
        }
    }
},
tooltip: {
    headerFormat: '<b>{point.x}</b><br/>',
},
plotOptions: {
    column: {
        stacking: 'normal',

    }
},
series: [{
        name: 'John',
        borderColor: '#0000FF',
        color: '#FFFFFF',
        data: [5, 3, 4, 7, 2]
    }, {
        name: 'Jane',
        borderColor: '#0000FF',
        color: '#0000FF',
        data: [2, 2, 3, 2, 1]
    },
    {

        //5-width
        //height 
        data: [
            [4, 10],
            [0, 10]
        ],
        lineWidth: 2,
        dashStyle: "Dash",
        lineColor: 'black',
        type: 'scatter',
        marker: {
            enabled: false
        },
        showInLegend: false,
        enableMouseTracking: false
    },
    {
        data: [
            [0, 20]
        ],
        lineWidth: 2,
        dashStyle: "Dash",
        lineColor: 'black',
        type: 'scatter',
        marker: {
            enabled: false
        },
        showInLegend: false,
        enableMouseTracking: false
    }
]
});

1 个答案:

答案 0 :(得分:0)

要创建此类行,应使用yAxis.plotLines

yAxis: {
    ...,
    plotLines: [{
        value: 10,
        zIndex: 2,
        width: 2,
        dashStyle: "Dash",
        color: 'black',

    }]
}

实时演示:https://jsfiddle.net/BlackLabel/ujyrz4h1/

API参考:https://api.highcharts.com/highcharts/yAxis.plotLines