Ecarts知识点积累(附示例)
- echarts知识点:
axisTick: { show:false, //隐藏x轴刻度 }, axisLine: { show: false, //隐藏x轴 }, //展示echarts图表中的数据,然后以柱形图或是其他形式的图形显示 series: [ { type: 'bar', data: [81, 78.9, 64.6, 63.6, 62, 61.4, 58.6, 57.3, 55.8, 38.4], barWidth: '34px', label: { normal: { show: true, position: 'top', formatter: (value) => value.value + '%', }, }, itemStyle: { normal: { color: '#3E7AFF', //改变图形颜色 barBorderRadius: [5, 5, 0, 0], //改变图形的形状,变成圆弧形 }, }, }, ],
- 示例:
var index = 0; var colorList = ['#f36c6c', '#e6cf4e', '#20d180', '#0093ff']; option = { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { show: false }, grid: { left: 100 }, toolbox: { show: true, feature: { saveAsImage: {} } }, xAxis: { type: 'value', //隐藏图表中的分割线 splitLine: { show: false }, //隐藏x轴下方的数据展示 axisLabel: { show: false }, //隐藏x轴中的刻度 axisTick: { show: false }, //隐藏x轴 axisLine: { show: false } }, yAxis: { type: 'category', inverse: true, axisLine: { show: false }, axisTick: { show: false }, axisPointer: { label: { show: true, margin: 30 } }, data: ['杭州', '宁波', '温州', '湖州', '嘉兴'], axisLabel: { margin: 100, fontSize: 14, align: 'left', color: '#333', //y轴旁边的序号样式 rich: { a1: { color: '#fff', backgroundColor: colorList[0], 30, height: 30, align: 'center', borderRadius: 2 }, a2: { color: '#fff', backgroundColor: colorList[1], 30, height: 30, align: 'center', borderRadius: 2 }, a3: { color: '#fff', backgroundColor: colorList[2], 30, height: 30, align: 'center', borderRadius: 2 }, b: { color: '#fff', backgroundColor: colorList[3], 30, height: 30, align: 'center', borderRadius: 2 } }, formatter: function(params) { if (index == 5) { index = 0; } index++; if (index - 1 < 3) { return [ '{a' + index + '|' + index + '}' + ' ' + params ].join(' ') } else { return [ '{b|' + index + '}' + ' ' + params ].join(' ') } } } }, series: [{ z: 2, name: 'value', type: 'bar', data: [3.66, 2.86, 1.82, 1.8, 1.53].map((item, i) => { itemStyle = { color: i > 3 ? colorList[3] : colorList[i] } return { value: item, itemStyle: itemStyle }; }), label: { show: true, position: 'right', color: '#333333', fontSize: 14, offset: [10, 0] } } ] };
示例图形如下: