|
@@ -62,226 +62,247 @@ category.forEach(value => {
|
|
|
|
|
|
function getOption() {
|
|
|
|
|
|
- nextTick(() => {
|
|
|
- let myChart = echarts.init(chartRef.value);
|
|
|
- let option = {
|
|
|
- xAxis: {
|
|
|
- max: 1000,
|
|
|
- splitLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
+
|
|
|
+ let myChart = echarts.init(chartRef.value);
|
|
|
+ let option = {
|
|
|
+ xAxis: {
|
|
|
+ max: 1000,
|
|
|
+ splitLine: {
|
|
|
+ show: false
|
|
|
},
|
|
|
- grid: {
|
|
|
- left: 10,
|
|
|
- top: 15, // 设置条形图的边距
|
|
|
- right: 10,
|
|
|
- bottom: 15
|
|
|
+ axisLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: 10,
|
|
|
+ top: 15, // 设置条形图的边距
|
|
|
+ right: 10,
|
|
|
+ bottom: 15
|
|
|
+ },
|
|
|
+ yAxis: [{
|
|
|
+ type: "category",
|
|
|
+ inverse: false,
|
|
|
+ data: category,
|
|
|
+ axisLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ show: false
|
|
|
},
|
|
|
- yAxis: [{
|
|
|
- type: "category",
|
|
|
- inverse: false,
|
|
|
- data: category,
|
|
|
- axisLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- show: false
|
|
|
- },
|
|
|
|
|
|
|
|
|
- }],
|
|
|
- series: [
|
|
|
- {
|
|
|
- // 内
|
|
|
- type: "bar",
|
|
|
- barWidth: 18,
|
|
|
- silent: true,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: function (param) {
|
|
|
- const colors = ['#ff0000', '#ff7700', '#d8b66f', '#dbbf2e', '#61b4c5',];
|
|
|
- return colors[param.dataIndex % colors.length];
|
|
|
- }
|
|
|
+ }],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ // 内
|
|
|
+ type: "bar",
|
|
|
+ barWidth: 18,
|
|
|
+ silent: true,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: function (param) {
|
|
|
+ const colors = ['#ff0000', '#ff7700', '#d8b66f', '#dbbf2e', '#61b4c5',];
|
|
|
+ return colors[param.dataIndex % colors.length];
|
|
|
}
|
|
|
- },
|
|
|
- label: {
|
|
|
- normal: {
|
|
|
- formatter: '{warnLevel1|{b}}', // 使用富文本占位符
|
|
|
- textStyle: {
|
|
|
- color: "#fff",
|
|
|
- fontSize: 14
|
|
|
- },
|
|
|
- position: [15, -26],
|
|
|
- show: true,
|
|
|
- rich: { //富文本
|
|
|
- warnLevel1: {
|
|
|
- backgroundColor: {
|
|
|
- image: 'image://' + warnLevel1,
|
|
|
- }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ // formatter: '{warnLevel1|}', // 使用富文本占位符
|
|
|
+ formatter: (params) => {
|
|
|
+ console.log(params,)
|
|
|
+ let text;
|
|
|
+ if (params.dataIndex == 0) {
|
|
|
+ text = `{warnLevel5|\u00A0\u00A0\u00A0\u00A0${params.data.name}}`;
|
|
|
+ } else if (params.dataIndex == 1) {
|
|
|
+ // text = `{warnLevel4|${params.data.name}}`;
|
|
|
+ } else if (params.dataIndex == 2) {
|
|
|
+ // text = `{warnLevel3|${params.data.name}}`;
|
|
|
+ } else if (params.dataIndex == 3) {
|
|
|
+ // text = `{warnLevel2|${params.data.name}}`;
|
|
|
+ } else if (params.dataIndex == 4) {
|
|
|
+ // text = `{warnLevel1|${params.data.name}}`;
|
|
|
+ }
|
|
|
+ return text;
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ fontSize: 12
|
|
|
+ },
|
|
|
+ position: [20, -21],
|
|
|
+ show: true,
|
|
|
+ rich: { //富文本
|
|
|
+ warnLevel1: {
|
|
|
+ backgroundColor: {
|
|
|
+ image: warnLevel1,
|
|
|
},
|
|
|
- warnLevel2: {
|
|
|
- backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
- image: 'image://' + warnLevel2,
|
|
|
- },
|
|
|
+ },
|
|
|
+ warnLevel2: {
|
|
|
+ backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
+ image: warnLevel2,
|
|
|
+
|
|
|
},
|
|
|
- warnLevel3: {
|
|
|
- backgroundColor: {
|
|
|
- image: 'image://' + warnLevel3,
|
|
|
- },
|
|
|
+ },
|
|
|
+ warnLevel3: {
|
|
|
+ backgroundColor: {
|
|
|
+ image: warnLevel3,
|
|
|
},
|
|
|
- warnLevel14: {
|
|
|
- backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
- image: 'image://' + warnLevel4,
|
|
|
- },
|
|
|
+ },
|
|
|
+ warnLevel4: {
|
|
|
+ backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
+ image: warnLevel4,
|
|
|
},
|
|
|
- warnLevel15: {
|
|
|
- backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
- image: 'image://' + warnLevel5,
|
|
|
- },
|
|
|
+ },
|
|
|
+ warnLevel5: {
|
|
|
+ backgroundColor: { //这里可以添加你想自定义的图片
|
|
|
+ image: warnLevel5,
|
|
|
},
|
|
|
-
|
|
|
+ height: 16,
|
|
|
+ width: 16,
|
|
|
+ align: 'left',
|
|
|
+ padding: [0, 5, 0, 0] // 右侧增加5px间距
|
|
|
},
|
|
|
|
|
|
- }
|
|
|
- },
|
|
|
- data: category,
|
|
|
- z: 1,
|
|
|
- animationEasing: "elasticOut"
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
+ data: category,
|
|
|
+ z: 1,
|
|
|
+ animationEasing: "elasticOut"
|
|
|
+ },
|
|
|
|
|
|
- {
|
|
|
- // 分隔
|
|
|
- type: "pictorialBar",
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: "rgba(28, 48, 52)"
|
|
|
- }
|
|
|
- },
|
|
|
- symbolRepeat: "fixed",
|
|
|
- symbolMargin: 3,
|
|
|
- symbol: "rect",
|
|
|
- symbolClip: true,
|
|
|
- symbolSize: [10, 24],
|
|
|
- symbolPosition: "start",
|
|
|
- symbolOffset: [1, -4],
|
|
|
- symbolBoundingData: 1000,
|
|
|
- data: [1000, 1000, 1000, 1000, 1000],
|
|
|
- z: 2,
|
|
|
- animationEasing: "elasticOut",
|
|
|
+ {
|
|
|
+ // 分隔
|
|
|
+ type: "pictorialBar",
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: "rgba(28, 48, 52)"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ symbolRepeat: "fixed",
|
|
|
+ symbolMargin: 3,
|
|
|
+ symbol: "rect",
|
|
|
+ symbolClip: true,
|
|
|
+ symbolSize: [10, 24],
|
|
|
+ symbolPosition: "start",
|
|
|
+ symbolOffset: [1, -4],
|
|
|
+ symbolBoundingData: 1000,
|
|
|
+ data: [1000, 1000, 1000, 1000, 1000],
|
|
|
+ z: 2,
|
|
|
+ animationEasing: "elasticOut",
|
|
|
|
|
|
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // label
|
|
|
+ type: "pictorialBar",
|
|
|
+ symbolBoundingData: 1000,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: "none"
|
|
|
+ }
|
|
|
},
|
|
|
- {
|
|
|
- // label
|
|
|
- type: "pictorialBar",
|
|
|
- symbolBoundingData: 1000,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: "none"
|
|
|
- }
|
|
|
- },
|
|
|
- label: {
|
|
|
- normal: {
|
|
|
- formatter: (params) => {
|
|
|
- let text;
|
|
|
- if (params.dataIndex == 0) {
|
|
|
- text = '{a| ' + params.data + '}';
|
|
|
- } else if (params.dataIndex == 1) {
|
|
|
- text = '{b| ' + params.data + '}';
|
|
|
- } else if (params.dataIndex == 2) {
|
|
|
- text = '{c| ' + params.data + '}';
|
|
|
- } else if (params.dataIndex == 3) {
|
|
|
- text = '{d| ' + params.data + '}';
|
|
|
- } else if (params.dataIndex == 4) {
|
|
|
- text = '{e| ' + params.data + '}';
|
|
|
- } else {
|
|
|
- text = '{f| ' + params.data + '}';
|
|
|
- }
|
|
|
-
|
|
|
- return text;
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ formatter: (params) => {
|
|
|
+ let text;
|
|
|
+ if (params.dataIndex == 0) {
|
|
|
+ text = '{a| ' + params.data + '}';
|
|
|
+ } else if (params.dataIndex == 1) {
|
|
|
+ text = '{b| ' + params.data + '}';
|
|
|
+ } else if (params.dataIndex == 2) {
|
|
|
+ text = '{c| ' + params.data + '}';
|
|
|
+ } else if (params.dataIndex == 3) {
|
|
|
+ text = '{d| ' + params.data + '}';
|
|
|
+ } else if (params.dataIndex == 4) {
|
|
|
+ text = '{e| ' + params.data + '}';
|
|
|
+ } else {
|
|
|
+ text = '{f| ' + params.data + '}';
|
|
|
+ }
|
|
|
+
|
|
|
+ return text;
|
|
|
+ },
|
|
|
+ rich: {
|
|
|
+ a: {
|
|
|
+ color: "#ff0000"
|
|
|
},
|
|
|
- rich: {
|
|
|
- a: {
|
|
|
- color: "#ff0000"
|
|
|
- },
|
|
|
- b: {
|
|
|
- color: "#ff7700"
|
|
|
- },
|
|
|
- c: {
|
|
|
- color: "#d8b66f"
|
|
|
- },
|
|
|
- d: {
|
|
|
- color: "#dbbf2e"
|
|
|
- },
|
|
|
- e: {
|
|
|
- color: "#61b4c5"
|
|
|
- },
|
|
|
- f: {
|
|
|
- color: "#fff"
|
|
|
- },
|
|
|
+ b: {
|
|
|
+ color: "#ff7700"
|
|
|
},
|
|
|
- position: [330, -15],
|
|
|
- show: true
|
|
|
- }
|
|
|
- },
|
|
|
- data: [612.5, 548.7, 300.2, 300, 299],
|
|
|
- z: 0,
|
|
|
+ c: {
|
|
|
+ color: "#d8b66f"
|
|
|
+ },
|
|
|
+ d: {
|
|
|
+ color: "#dbbf2e"
|
|
|
+ },
|
|
|
+ e: {
|
|
|
+ color: "#61b4c5"
|
|
|
+ },
|
|
|
+ f: {
|
|
|
+ color: "#fff"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ position: [330, -15],
|
|
|
+ show: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: [612.5, 548.7, 300.2, 300, 299],
|
|
|
+ z: 0,
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ name: "外框",
|
|
|
+ type: "bar",
|
|
|
+ barGap: "-130%", // 设置外框粗细
|
|
|
+ data: [1000, 1000, 1000, 1000, 1000],
|
|
|
|
|
|
+ barWidth: 29,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ barBorderRadius: [0, 0, 0, 0],
|
|
|
+ color: "transparent", // 填充色
|
|
|
+ barBorderColor: "#3ecca7", // 边框色
|
|
|
+ barBorderWidth: 1, // 边框宽度
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- {
|
|
|
- name: "外框",
|
|
|
- type: "bar",
|
|
|
- barGap: "-130%", // 设置外框粗细
|
|
|
- data: [1000, 1000, 1000, 1000, 1000],
|
|
|
-
|
|
|
- barWidth: 29,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- barBorderRadius: [0, 0, 0, 0],
|
|
|
- color: "transparent", // 填充色
|
|
|
- barBorderColor: "#3ecca7", // 边框色
|
|
|
- barBorderWidth: 1, // 边框宽度
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- z: 0
|
|
|
+ z: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'scatter',
|
|
|
+ name: '条形',
|
|
|
+ symbol: 'roundRect',
|
|
|
+ symbolSize: [6, 14],
|
|
|
+ symbolOffset: [3, -3],
|
|
|
+ symbolKeepAspect: true,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: "#3ecca7"
|
|
|
+ }
|
|
|
},
|
|
|
- {
|
|
|
- type: 'scatter',
|
|
|
- name: '条形',
|
|
|
- symbol: 'roundRect',
|
|
|
- symbolSize: [6, 14],
|
|
|
- symbolOffset: [3, -3],
|
|
|
- symbolKeepAspect: true,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- color: "#3ecca7"
|
|
|
- }
|
|
|
- },
|
|
|
- data: [1000, 1000, 1000, 1000,1000],
|
|
|
- }
|
|
|
+ data: [1000, 1000, 1000, 1000, 1000],
|
|
|
+ }
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ myChart.setOption(option);
|
|
|
+ window.onresize = function () {
|
|
|
+ myChart.resize();
|
|
|
+ };
|
|
|
|
|
|
- ]
|
|
|
- }
|
|
|
- myChart.setOption(option);
|
|
|
- window.onresize = function () {
|
|
|
- myChart.resize();
|
|
|
- };
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
|