如何用4 Y轴制作图表

时间:2017-07-16 13:31:05

标签: javascript jquery graph charts highcharts

我想用4 Y轴制作图表。我知道如何制作双Y轴图,但是我不能用4 y轴制作图。我已经包含了一个双Y轴graph的例子。请在这个双y轴图中帮我做4 y轴曲线图。



Highcharts.chart('container', {
    chart: {
        marginRight: 80 // like left
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    yAxis: [{
        lineWidth: 1,
        title: {
            text: 'Primary Axis'
        }
    }, {
        lineWidth: 1,
        opposite: true,
        title: {
            text: 'Secondary Axis'
        }
    }],

    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]
    }, {
        data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2],
        yAxis: 1
    }]
});

<div id="container" style="height: 400px"></div>
<script src="https://code.highcharts.com/highcharts.js"></script>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

与两轴相同。

在yAxis部分中定义4轴,在系列部分中指定哪些数据进入哪个轴。

    yAxis: [{
        lineWidth: 1,
        title: {
            text: 'Primary Axis'
        }
    }, {
        lineWidth: 1,
        opposite: true,
        title: {
            text: 'Secondary Axis'
        }
    }, {
        lineWidth: 1,
        opposite: false,
        title: {
            text: 'third Axis'
        }
    }, {
        lineWidth: 1,
        opposite: false,
        title: {
            text: 'fourth Axis'
        }
    }],

    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]
    }, {
        data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2],
        yAxis: 1
    }, {
        data: [44.0, 76.0, 35.6, 48.5, 116.4, 180.1, 195.6, 154.4, 129.9, 72.5, 108.4, 159.2],
        yAxis: 2
    }, {
        data: [ 95.6, 54.4, 29.9, 71.5, 106.4, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1,129.2],
        yAxis: 3
    }]

here是你的小提琴