【数据可视化】【highcharts】多轴x轴改为日期格式--实例

本文介绍了如何在Highcharts中将多轴X轴设置为日期格式,适用于数据可视化的场景。通过实例展示,作者h.k在2018年1月16日分享了这一知识,强调个人知识梳理,转载请注明出处。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

数据可视化

highcharts

实例


  • 时间轴 -> X-axis
  • 多组测量数据轴 -> 多个Y-axis
    var optionView = {
        //chart 属性 包括 图表背景
        chart: {
            type: 'line',
            backgroundColor: 'rgba(0,0,0,0)'
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        //在X-axis 设置X-axis 属性,eg. 日期格式
        xAxis: {
            type: 'datetime',
            lineWidth: 0,
            tickWidth: 0,
            labels: {
                enabled: true
            }
        },
        //针对不同类型图表的配置
        //eg. pointStart,pointInterval
        plotOptions: {
            series: {
                label: {
                    connectorAllowed: true
                },
                pointStart: Date.UTC(startTime),
                pointInterval: 4 * 3600 * 1000 // one day
            }
        },
        //多Y-axis 使用{[Y0],[Y1]}区分
        //tickPositions :尺度
        yAxis: [{
                tickPositions: [30, 32, 34, 36, 38, 40, 42],
                gridLineColor: '#C0C0C0',
                gridLineDashStyle: 'solid',
                gridLineWidth: '0',
                lineColor: '#ffffff',
                title: {
                    text: ''
                },
                labels: {
                    enabled: true
                }
            }, {
                tickPositions: [40, 70, 100, 130, 160, 190, 220],
                gridLineColor: '#C0C0C0',
                gridLineDashStyle: 'solid',
                gridLineWidth: '0',
                lineColor: '#ffffff',
                title: {
                    text: ''
                },
                labels: {
                    enabled: true
                }
            }, {
                tickPositions: [40, 60, 80, 100, 120, 140, 160],
                gridLineColor: '#C0C0C0',
                gridLineDashStyle: 'solid',
                gridLineWidth: '0',
                lineColor: '#ffffff',
                title: {
                    text: ''
                },
                labels: {
                    enabled: true
                }
            }],
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            enabled: true
        },
        //版权信息
        credits: {
            enabled: true,
            text: "h.k 2018年1月15日"
        },
        //导出
        exporting: {
            enabled: true
        },
        //series 为数据载体对象
        //对应设定的多个Y-Axis 使用[yAxis:下标int]对应
        //数据格式改为 data:[[x1,y1],[x2,y2]]
        series: [{
                yAxis: 0,
                name: '',
                color: 'none',
                data: dataTW
            }, {
                yAxis: 1,
                name: '',
                data: dataMB
            }, {
                yAxis: 2,
                name: '',
                color: '#00ff00',
                data: dataXY_high
            }, {
                yAxis: 2,
                name: '',
                color: '#00ff00',
                data: dataXY_low
            }],
        responsive: {
            rules: [{
                    condition: {
                        maxWidth: 500
                    },
                    chartOptions: {
                        legend: {
                            layout: 'horizontal',
                            align: 'center',
                            verticalAlign: 'bottom'
                        }
                    }
                }]
        }
    }

    var charts = Highcharts.chart('container', optionView);

个人知识梳理,转载请标明署名

——by h.k 2018年1月16日

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值