关于echarts y轴坐标刻度的问题

问题描述

需求是有一组数据data,dat.x为x轴时间横坐标,data.y为y轴data,data.y的竖直范围在1上下波动,现在需要将曲线图的原点坐标的y坐标变为以1起始,超出1的部分在x轴上方,低于1就在x轴下面,现在的曲线图如下

问题出现的环境背景及自己尝试过哪些方法


图片描述

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)
var option = {

    tooltip: {
        trigger: 'axis',
    },
    xAxis : [ {
        show:true,
        type: 'category',
        boundaryGap: false,
        axisLine:{
            show:true,
        },
        axisTick:{
            show:false
        },
        axisLabel:{
            show:false
            },
        splitLine:{
            show:false,
        },
        data : strategyInfo.x
    } ],
    yAxis : [{
        show : true,
        axisLine : {
            show : true,
            lineStyle : {
                color : "#bae1e5"
            }
        },
        scale: true,
        axisTick : {
            show : true
        },
        axisLabel:{
            show:true
            },
        position : 'left',
        type : 'value',
        boundaryGap : [ 0, '15%' ],
        splitLine : {
            show : false,
            interval : 1000,
            lineStyle : {
                color : "#bae1e5"
            }
        },

    }],
    series : [ {
        name : '净值',
        type : 'line',
        xAxisIndex : 0,
        yAxisIndex : 0,
        data : strategyInfo.y,
        smooth : true,
        symbol : 'none',
        sampling : 'average',
        itemStyle : {
            normal : {
                color : 'rgb(164, 215, 220)'
            }
        },
        areaStyle : {
            normal : {
                color : 'rgb(164, 215, 220)'
            }
        },
    } ]
};

你期待的结果是什么?实际看到的错误信息又是什么?

阅读 9.1k
1 个回答

可以试试设置xAxis.offset
不过这样offset是个固定值,如果图表大小发生变化不好做自适应

推荐问题