
option = { tooltip: { //浮窗设置 trigger: 'item', textStyle: { fontSize: 40 }, padding: [20, 20, 20, 20], borderWidth: 2, formatter: function (params) { //不知道params里面的参数可以打印出来看 return ( `${params.name}<br/>` + `<span style="display:inline-block;margin-right:10px;border-radius:50%;width:20px;height:20px;background-color:${params.color.colorStops[0].color};"></span>` + `${params.value}` ); } }, grid: { //设置图表内容范围 left: '0', right: '0', bottom: '0', top: '10', containLabel: true }, xAxis: { //x轴 type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], axisLine: { //设置x坐标轴 show: true, lineStyle: { color: '#333' } }, axisLabel: { //设置x坐标轴标签 show: true, textStyle: { fontSize: 24, color: '#f00' } }, axisTick: { //坐标轴刻度设置 show: false } }, yAxis: { //y 轴 type: 'value', axisLine: { //设置y坐标轴 show: true, lineStyle: { color: '#333' } }, axisTick: { //坐标轴刻度设置 show: false }, axisLabel: { //设置y坐标轴标签 show: true, textStyle: { fontSize: 20, color: '#f00' } }, splitLine: { //坐标轴在 grid 区域中的分隔线(中间的网格线) lineStyle: { color: '#333', width: 1, type: 'dashed' } } }, series: [ { data: [120, 200, 150, 80, 70, 110, 130], type: 'bar', barWidth: 72, //设置柱子宽度 label: { //设置图形上的文本标签(不需要则不用设置) show: true, fontSize: '32', color: '#fff', position: 'insideTop', //top / left / right / bottom / inside / insideLeft / insideRight / insideTop / insideBottom / insideTopLeft / insideBottomLeft / insideTopRight / insideBottomRight formatter: function (params) { return params.value; } }, itemStyle: { color: function (params) { //每条柱子设置渐变色 var colorList = [ ['rgba(73, 158, 251, 1)', 'rgba(73, 104, 251, 0)'], ['rgba(170, 135, 255, 1)', 'rgba(171, 106, 255, 0)'], ['rgba(163, 222, 36, 1)', 'rgba(134, 184, 28, 0)'], ['rgba(255, 155, 208, 1)', 'rgba(235, 129, 185, 0)'], ['rgba(255, 139, 0, 1)', 'rgba(255, 110, 0, 0)'], ['rgba(255, 0, 0, 1)', 'rgba(235, 0, 0, 0)'], ['rgba(0, 255, 0, 1)', 'rgba(0, 255, 0, 0)'] ]; var colorItem = colorList[params.dataIndex]; return new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: colorItem[0] }, { offset: 1, color: colorItem[1] } ], false ); } } } ]};