echarts

设置折线颜色和小圆点颜色

series: [{
    name: "seriesName",
    type: "line",
    symbol: 'emptyCircle', //设置为空心圆点
    smooth:true,  //这个是把线变成曲线
    itemStyle: {
        normal: {
            color: "#2ec7c9", //设置小圆点颜色
            lineStyle: {
                color: "#2ec7c9" //设置折线颜色
            }
        }
    },
    data: [9550, 9700]
}]

实现双y轴

yAxis: [{ 
	type: 'value',
	name: '元/吨',
	min: 7000,
	max: 10000,
	splitNumber:6,
	axisLabel: { //y轴字体色
		show: true,
		textStyle: {
			color: '#6e7f93'
		}
	},
	axisLine:{ //y轴坐标线
		lineStyle:{
			color:'#6e7f93',
			width:1,
		}
	}			          
},{ 
	type: 'value',
	name: '元/吨',
	min: 0,
	max: 750,
	splitNumber:6,
	axisLabel: { //y轴字体色
		show: true,
		textStyle: {
			color: '#6e7f93'
		}
	},
	axisLine:{ //y轴坐标线
		lineStyle:{
			color:'#6e7f93',
			width:1,
		}
	},
	axisTick:{
		show:false //是否显示坐标轴刻度
	}				
}]

series中通过字段yAxisIndex来指定应用哪个y轴,计数从0开始。

series: [{
            name: '价差',
            type: 'line',
            yAxisIndex: 1, //第二个y轴
            data: [10, 23, 58]
        }, {
            name: 'pp',
            type: 'line',
            data: [644183, 945711, 965962]
        }, {
            name: 'pe',
            type: 'line',
            data: [55096, 27366, 289103]
        }
}]

tooltip信息添加单位

tooltip: {
    trigger: 'axis',	
    showContent: true,
    axisPointer:{ //垂直指示线线条颜色
        lineStyle: {
            color: '#ccc',
            width: 1,
            type: 'solid'
        }
    },
    /*formatter:function(params){   //吨数加单位
       var relVal = params[0].name;  
       for (var i = 0, l = params.length; i < l; i++) {  
            relVal += '<br/>' + params[i].seriesName + ' : ' + params[i].value+"元/吨";  
        }  
       return relVal;  
    }  */
    formatter: function (params,ticket,callback) {
        var resDate = params[0].name;
        var res = '';
        var resRes = '';
        for (var i = 0, l = params.length; i < l; i++) {
            switch(params[i].seriesName) {
                case 'PP现货':
                    res += 'PP现货:' + '<span style="color: #e5481d;">';
                break;					
                case 'PP期货':
                    res += 'PP期货:' + '<span style="color: #6080e5;">';
                break;					
                case '价差':
                    res += '价差:' + '<span style="color: #bf89e1;">';
                break;
                default:
                break;
            }
            res += params[i].value + '</span>元/吨<br/>';
            resRes = resDate + '<br/>' + res;
        }
       return resRes;
      
    }//吨数字体变色	
},

整体宽度放宽

grid: {
	width:"86%", //图表宽度放宽
	height:'65%'
}

去除最外部边框

grid: {show:'true',borderWidth:'0'}, //在option中,插入这句代码

去掉拖拽重计算

calculable: false

x轴设置

xAxis: [{
    type: 'category',
    boundaryGap: false, //坐标轴两端空白策略
    splitLine:{
        show:false //去掉坐标轴在grid区域中的纵向分隔线
    },   
    axisLabel: { //x轴字体色
        show: true,
        textStyle: {
            color: '#6e7f93'
        }
    }, 
    axisLine:{ //x轴坐标线
        lineStyle:{
            color:'#6e7f93',
            width:1,
        }
    },				          
    data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
}]

图例横向/纵向显示

legend: {
    orient: 'vertical', //加上这句就是纵向显示,删除就是横向显示
    left: 'left'
},

折现图的点上添加数值

series的itemStyle中添加

label: {
  show: true,
  fontSize: 10,
  formatter: function (params) {
    return (params.value + "%");
  }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值