xAxis: [{type: 'category',data: [materialUserEchartsDate.value[0] ? materialUserEchartsDate.value[0].name : '',materialUserEchartsDate.value[1] ? materialUserEchartsDate.value[1].name : '',materialUserEchartsDate.value[2] ? materialUserEchartsDate.value[2].name : '',materialUserEchartsDate.value[3] ? materialUserEchartsDate.value[3].name : '',materialUserEchartsDate.value[4] ? materialUserEchartsDate.value[4].name : ''],axisLabel: {interval: 0,// rotate: -10,textStyle: {fontSize: 10},formatter: function (value) {let maxLength = 5 //每项显示文字个数if (value.length > maxLength) {value = value.substring(0, maxLength) + '...' // 用省略号代替多余的字}return value}},axisPointer: {type: 'shadow'},axisTick: {show: false // 隐藏x轴的刻度}}],
legend: {orient: 'vertical',left: 190, // 图例位置y: 'center',textStyle: {color: '#fff',fontSize: 10},itemHeight: 10,itemWidth: 10,formatter: function (name) { // 图例后显示值var data = option.series[0].data //获取series中的datavar total = 0var tarValuefor (var i = 0, l = data.length; i < l; i++) {total += data[i].valueif (data[i].name == name) {tarValue = data[i].value}}if (name.length > 5) { // 如果长度大于5则用省略号代替name = name.slice(0, 5) + '...'}return name + ' ' + ' ' + tarValue}},
如果想要以上echarts图形完整代码,可以访问
https://gitee.com/abcdfdewrw/echarts_library