用高图中的垂直线连接两个不同的值

web*_*.ic 1 jquery charts highcharts

嗨,我正在为我的网站寻找一个好的图表插件。我找到了 highcharts,它解决了我的大部分需求。现在我用这个插件构建了如下图表:

$(function () {
    $('#container').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Connect Values'
        },
        subtitle: {
            text: 'Value 1 and Value 2'
        },
        xAxis: [{
            categories: ['24.05.2015', '01.06.2015', '12.06.2015', '19.06.2015', '25.06.2015'],
            crosshair: true
        }],
        yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: 'Value 1',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            }
        }, { // Secondary yAxis
            title: {
                text: 'Value 2',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            opposite: true
        }],
        tooltip: {
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            x: 120,
            verticalAlign: 'top',
            y: 100,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
        },
        series: [{
            name: 'Value 2',
            type: 'spline',
            yAxis: 1,
            data: [77, 69, 89, 84, 86],
            tooltip: {
                valueSuffix: ''
            }

        }, {
            name: 'Value 1',
            type: 'spline',
            data: [120, 118, 126, 129, 135],
            tooltip: {
                valueSuffix: ''
            }
        }]
    });
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
Run Code Online (Sandbox Code Playgroud)

现在我想用一条垂直线从点到点连接两条不同线的区域中的两个值,如下所示:

在此处输入图片说明

或者这也是可能的:

在此处输入图片说明

我可以在 highcharts 中做到这一点吗?或者是否有其他图表插件也包含多个 y 轴(2 个或更多)并且可以连接值?我希望得到一些帮助。

谢谢。

Seb*_*han 5

您可以将样条系列与 columnrange 类型结合使用。然后设置 pointWidth参数来声明每列的大小:

    series: [{
        type:'columnrange',
        pointWidth: 2,
        data: [[5,10],[4,5],[10,20],[12,15],[15,19]]
    },{
        data: [10,5,20,15,19]
    }, {
        data: [5,4,10,12,15]
    }]
Run Code Online (Sandbox Code Playgroud)

例子: