echart中的tooltip.axisPointer. type = ‘cross‘格式化x轴标签

tooltip : {
            trigger : 'axis',
            axisPointer: {
                type: 'cross'
            },
            position: function (pos, params, dom, rect, size) {
                // 鼠标在左侧时 tooltip 显示到右侧,鼠标在右侧时 tooltip 显示到左侧。
                var obj = {top: 20};
                obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5;
                return obj;
            }
        }

//x轴的时间类型为long类型

xAxis : {
            type : 'time',
            splitNumber: 13,
            interval : 21600,
            axisLabel : {
                formatter : function(value, index) {
                    // 将时间转换成"00:00:00"格式
                    var hms = ;
                    return hms;
                }
            },
            splitLine : {
                show : false
            },
            axisPointer: {
                link: {xAxisIndex: 'all'},
                label: {
                    backgroundColor: '#777',
                    // 文本标签文字的格式化器
                    formatter: function (params) {
                        return ;
                    }
                },
            },
            data : []
        }

 

  echarts官方文档地址:https://echarts.apache.org/zh/option.html

具体需求以及标签含义可参考官方文档

 

 

 

 

 

let option = { title: { text: '氧含量趋势图', left: 'center', feature: { magicType: {type: ['line', 'bar']}//此处最新版本echarts可设置三个值(stack-堆叠模式),可自行查看echarts文档 } }, xAxis: { type: 'time', axisLine: { // X 线样式 lineStyle: { color: '#999999' } }, axisLabel: { // X 刻度标签样式 color: '#999999', formatter: function (value) { // 格式化 X 标签显示 return echarts.format.formatTime('hh:mm:ss', value); } }, splitLine: { // X 分隔线样式 lineStyle: { color: '#EEEEEE' } }, min: that.X_axis_and_Y_axis.X[0], max: that.X_axis_and_Y_axis.X[Last_digit_of_X_axis], }, yAxis: { type: 'value', axisLine: { // Y 线样式 lineStyle: { color: '#999999' } }, axisLabel: { // Y 刻度标签样式 color: '#999999' }, splitLine: { // Y 分隔线样式 lineStyle: { color: '#EEEEEE' } }, splitArea: { // Y 背景色配置 show: true, areaStyle: { color: { colorStops: [{ offset: 0, color: 'rgba(135, 206, 235, 0.8)' // 渐变起始色 }, { offset: 1, color: 'rgba(135, 206, 235, 0.2)' // 渐变结束色 }], globalCoord: false } } } }, series: [{ type: 'line', name: '氧气', data: that.X_axis_and_Y_axis.Y, // 替换为你的 Y 数据数组 // data: that.X_axis_and_Y_axis.Y, // 替换为你的 Y 数据数组 lineStyle: { color: '#FF0000', // 替换为你的线条颜色 width: 1 } }], tooltip: { trigger: 'axis', axisPointer: { type: 'cross' }, formatter: function (params) { var xValue = params[0].axisValue; var yValue = params[0].data; return '时间:' + xValue + '<br/>数据:' + yValue; } } };其的data: that.X_axis_and_Y_axis.Y,只显示了刻度并没有显示趋势
07-20
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值