Highcharts 实现双X轴

var chart;
$(function () {
            $(document).ready(function () {
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'container'
                    },
                    title: {
                        text: '正标题'
                    },
                    subtitle: {
                        text: 'Source: www.stepday.com'
                    },
                    //这里配置了多个X轴
                    xAxis: [{
                        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
                        title: {
                            text: '月份',
                            style: {
                                color: '#89A54E'
                            }
                        }
                    }, {
                        categories: ['X', 'Y', 'Z', 'W', 'V', 'I',
                    'J', 'K', 'L', 'M', 'N', 'O'],
                        title: {
                            text: '字母',
                            style: {
                                color: '#89A54E'
                            }
                        },
                        opposite: true //对立面 表示显示在上方   不写默认显示在底部 
                    }],
                    yAxis: [{
                        labels: {
                            formatter: function () {
                                return this.value + '°C';
                            },
                            style: {
                                color: '#89A54E'
                            }
                        },
                        title: {
                            text: 'Temperature',
                            style: {
                                color: '#89A54E'
                            }
                        }
                    }],
                    tooltip: {
                        formatter: function () {
                            return '' +
                        this.x + ': ' + this.y +
                        (this.series.name == 'Rainfall' ? ' mm' : '°C');
                        }
                    },
                    credits: {
                       text:"www.stepday.com",
                       href:'http://www.stepday.com/myblog/?highcharts'
                    },                  
                    series: [{
                        name: 'Rainfall',
                        color: '#4572A7',
                        type: 'column',
                        xAxis: 1,//第二个X轴
                        data: [-30, -40, 0, -129.2, -144.0, -176.0, -35.6, -48.5, -16.4, -94.1, -5.6, -4.4]

                    }, {
                        name: 'Temperature',
                        color: '#89A54E',
                        type: 'column',
                        data: [0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                    }]
                });
            });
});

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值