highcharts:在1个图表中绘制2个图表的问题

时间:2015-07-17 05:52:55

标签: highcharts

我在1张图表中有2张图表。第一个图形的x轴值范围是1到100.第二个图形的x轴值范围是1到30.因此,当在图表中绘制图形时,第二个图形被绘制得非常小面积。因此,阅读第二张图变得困难。我的要求 - 两个图表都是可读的。有人可以帮我这样做吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可以设置两个轴 - 每个系列一个。

示例:http://jsfiddle.net/4v0a07op/

$(function () {
    $('#container').highcharts({
        title: {
            text: 'Monthly Average Temperature',
            x: -20 //center
        },
        subtitle: {
            text: 'Source: WorldClimate.com',
            x: -20
        },
        xAxis: [{
        },{
            opposite: true
        }],
        yAxis: {
            title: {
                text: 'Temperature (°C)'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        series: [{
            name: '1 to 30',
            xAxis: 1,
            data: [11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,18,19,10]
        }, {
            name: '1 to 100',
            xAxis: 0,
            data: [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]
        }]
    });
});