echarts 绘制 坐标值 垂直水平

 

 

 

https://www.echartsjs.com/examples/zh/editor.html?c=line-simple

将下面的代码拷入后运行,enjoy吧



//markline
        var markLineOpt = {
            symbol: 'none',
            itemStyle: {
                normal: { lineStyle: { type: 'dotted', color:'#000' } }
            },
            data: [
                [{
                    // 固定起点的 x 像素位置,用于模拟一条指向最大值的水平线
                    yAxis: '820',
                    xAxis: '820'
                }, {
                    yAxis: '0',
                    xAxis: '820'
                }],

            ]
        };
        //图表
     
option = {
            backgroundColor:'',
            grid: {
                top: '15%',
                bottom:'25%',
                left:'0',
                right:'0',
                containLabel: false
            },
            xAxis: [
                {
                    type: 'category',
                    data:  [820, 932, 901, 934, 1290, 1330], //x轴数据
                    axisTick:{
                        show:false,
                    },
                    axisLine:{
                        lineStyle:{
                            color:'#f8914e',
                            width:1
                        }
                    },
                    axisLabel:{
                        textStyle:{
                            color:function(value,index){
                                return index%2==0?'#da241e':'#ffc770'
                            }
                        },
                        fontSize:12,
                        interval:0
                    },
                },
                {
                    type: 'category',
                    data:  [820, 932, 901, 934, 1290, 1330],//图表中间显示年份参数
                    position: 'bottom',
                    axisTick:{
                        show:false
                    },
                    axisLine:{
                        lineStyle:{
                            color:'transparent',
                            width:0
                        }
                    },
                    axisLabel:{
                        textStyle:{
                            color:function(value,index){
                                return index%2==0?'#da241e':'#ffc770'
                            }
                        },
                        fontSize:12,
                        interval:0
                    },
                    offset: 15,
                },
                {
                    type: 'category',
                    data:  [820, 932, 901, 934, 1290, 1330],//图表中间显示月份参数
                    axisTick:{
                        show:false
                    },
                    axisLine:{
                        lineStyle:{
                            color:'transparent',
                            width:0
                        }
                    },
                    axisLabel:{
                        textStyle:{
                            color:function(value,index){
                                return index%2==0?'#da241e':'#ffc770'
                            }
                        },
                        fontSize:14,
                        interval:0
                    },

                }
            ],
            yAxis: {
                type: 'value',
                axisTick:{
                    show:false,
                    alignWithLabel: true
                },
                splitLine:{show: false},//去除网格线
                axisLabel:{
                    formatter:function(){
                        return ""
                    }
                },
                axisLine:{
                    lineStyle:{
                        color:'#f8914e',
                        width:1,

                    }
                }
            },
            series: [
                /*{
                    name:'',
                    data: [], //柱状图数据,与x轴数据对应
                    type: 'bar',
                    barWidth:20,
                    itemStyle: {
                        normal: {
                            color: function(param) {
                                var colorList = [ "#da241e", "#ffc770" ];
                                var x = '';
                                param.dataIndex%2 ==0 ? x=1 : x=2;
                                if(x == '1') {
                                    return colorList[0];
                                } else {
                                    return colorList[1]
                                }
                            },
                            barBorderRadius: [3,3,0,0],
                        },
                    },
                },*/
                {
                    name:'',
                    data:  [820, 932, 901, 934, 1290, 1330],//柱状图上方折线图数据,在柱状图数据基础上+3向上调整位置
                    type:'line',
                    lineStyle:{
                        color:'#FFC770',
                    },
                    label: {
                        show: true,
                        position: 'top'
                    },
                    itemStyle:{
                        normal:{
                            color: function(param) {
                                var colorList = [ "#da241e", "#ffc770" ];
                                var x = '';
                                param.dataIndex%2 ==0 ? x=1 : x=2;
                                if(x == '1') {
                                    return colorList[0];
                                } else {
                                    return colorList[1]
                                }
                            },
                        }
                    },
                    markLine: markLineOpt,
                    symbol: 'emptyCircle',
                    symbolSize: 10
                }
            ]
        };

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未来AI编程

共鸣===鼓励 打赏您随意

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值