简体   繁体   English

在highcharts中有可能有2个图表,共享相同的x轴,但彼此相邻吗?

[英]Is it possible in highcharts to have 2 charts, sharing the same x-axis, but next to one another?

I found this: 我找到了这个:

http://jsfiddle.net/tungwaiyip/F3pts/6/ http://jsfiddle.net/tungwaiyip/F3pts/6/

But that's not what I want. 但这不是我想要的。 I need to have something similar but with the charts sharing the x-axis. 我需要有类似的东西,但图表共享x轴。

        top: 300;

The above setting in the yAxis does the trick on the y axis but I can't see anything like that for the x-axis. yAxis中的上述设置在y轴上进行了技巧,但我看不到x轴的那种情况。

Is it possible in highcharts to have 2 charts, sharing the same x-axis, but next to one another? 在highcharts中有可能有2个图表,共享相同的x轴,但彼此相邻吗?

Here is my fiddle: http://jsfiddle.net/PcWSu/ 这是我的小提琴: http//jsfiddle.net/PcWSu/

The same properties you can use for xAxis (top, left, width, height), see: http://jsfiddle.net/F3pts/7/ 您可以用于xAxis(顶部,左侧,宽度,高度)的相同属性,请参阅: http//jsfiddle.net/F3pts/7/

xAxis: [{
    gridLineWidth: 1,
    width :150
}, {
    offset: 0,
    gridLineWidth: 1,
    width :150,
    left: 230
}],

You can go through this fiddle where in you can see shared tooltip with multiple X and Y axis. 您可以通过这个小提琴在哪里可以看到具有多个X和Y轴的共享工具提示。 Hope this will help. 希望这会有所帮助。

$(function () {
    $('#container').highcharts({
        title: {
            text: 'Shared tooltip chart'
        },
        xAxis: [{
            type: 'datetime',
            id: 'x1'
        }, {
            type: 'datetime',
            id: 'x2',
            opposite: true
        }],
        yAxis: {
            min: 0
        },
        tooltip: {
            shared: true,
            useHTML: true,
            formatter: function () {
                var tooltip = '';
                var i, len;
                tooltip += '<small>Apple</small>';
                tooltip += '<table>';
                for (i = 0, len = 4; i < len; i++) {
                        if(this.points[i] != undefined){
                if(this.points[i].series.name.indexOf('Apple') >= 0){
                    tooltip += '<tr>';
                    tooltip += '<td style="color: ' + this.points[i].series.color + '">\u25CF</td>';
                    tooltip += '<td>' + Highcharts.dateFormat('%Y-%m-%d', this.points[i].x) + ':</td>';
                    tooltip += '<td style="text-align: right"><b>' + this.points[i].y + '</b></td>';
                    tooltip += '</tr>';
                    }
                    }
                }
                tooltip += '</table>';
                tooltip += '<small>Mango</small>';
                tooltip += '<table>';
                for (i = 0, len = 4; i < len; i++) {
                        if(this.points[i] != undefined){
                if(this.points[i].series.name.indexOf('Mango') >= 0){
                    tooltip += '<tr>';
                    tooltip += '<td style="color: ' + this.points[i].series.color + '">\u25CF</td>';
                    tooltip += '<td>' + Highcharts.dateFormat('%Y-%m-%d', this.points[i].x) + ':</td>';
                    tooltip += '<td style="text-align: right"><b>' + this.points[i].y + '</b></td>';
                    tooltip += '</tr>';
                    }
                    }
                }
                tooltip += '</table>';
                return tooltip;
            }
        },
        series: [{
            name: 'Apple',
            id: 'series1',
            xAxis: 'x1',
            color: 'rgba(255, 0, 0, 1.0)',
            data: [5, 3, 4, 7, 6, 1, 0],
            pointInterval: 1000 * 60 * 60 * 24,
            pointStart: Date.UTC(2015, 2, 10)
        }, {
            name: 'Apple New',
            id: 'series2',
            //linkedTo: 'series1',
            xAxis: 'x2',
            color: 'rgba(255, 180, 180, 1.0)',
            data: [4, 5, 5, 6, 1, 3, 4],
            pointInterval: 1000 * 60 * 60 * 24,
            pointStart: Date.UTC(2015, 2, 17)
        },{
            name: 'Mango',
            id: 'series3',
            xAxis: 'x1',
            color: 'rgba(255, 0, 0, 1.0)',
            data: [15, 13, 14, 17, 16, 11, 10],
            pointInterval: 1000 * 60 * 60 * 24,
            pointStart: Date.UTC(2015, 2, 10)
        }, {
            name: 'Mango New',
            id: 'series4',
            //linkedTo: 'series1',
            xAxis: 'x2',
            color: 'rgba(255, 180, 180, 1.0)',
            data: [14, 15, 15, 16, 11, 13, 14],
            pointInterval: 1000 * 60 * 60 * 24,
            pointStart: Date.UTC(2015, 2, 17)
        }]
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM