Commit bad53ff7f2e7eee8e0e1768a92733cfa438e437e

Authored by 梁保满
1 parent 5e11badb

echart y轴最小间隔

src/components/charts/barChart.vue
@@ -28,7 +28,7 @@ export default { @@ -28,7 +28,7 @@ export default {
28 // this.initData(); 28 // this.initData();
29 }, 29 },
30 methods: { 30 methods: {
31 - setOption(xAxis,params) { 31 + setOption(xAxis, params) {
32 const that = this; 32 const that = this;
33 const options = { 33 const options = {
34 color: this.colors || ["#4472c4", "#ed7d32", "#a5a5a5"], 34 color: this.colors || ["#4472c4", "#ed7d32", "#a5a5a5"],
@@ -64,6 +64,7 @@ export default { @@ -64,6 +64,7 @@ export default {
64 }, 64 },
65 yAxis: { 65 yAxis: {
66 type: "value", 66 type: "value",
  67 + minInterval: 1,
67 axisLine: { show: true, lineStyle: { color: "#e2e2e2" } }, 68 axisLine: { show: true, lineStyle: { color: "#e2e2e2" } },
68 splitLine: { 69 splitLine: {
69 show: true, 70 show: true,
@@ -105,13 +106,13 @@ export default { @@ -105,13 +106,13 @@ export default {
105 }; 106 };
106 return options; 107 return options;
107 }, 108 },
108 - initData(xAxis,params) { 109 + initData(xAxis, params) {
109 if (!xAxis.length) return; 110 if (!xAxis.length) return;
110 if (!this.chart) { 111 if (!this.chart) {
111 const div = document.getElementById(this.id); 112 const div = document.getElementById(this.id);
112 this.chart = this.$echarts.init(div); 113 this.chart = this.$echarts.init(div);
113 } 114 }
114 - const options = this.setOption(xAxis,params); 115 + const options = this.setOption(xAxis, params);
115 this.chart?.clear(); 116 this.chart?.clear();
116 this.chart.setOption(options, true); 117 this.chart.setOption(options, true);
117 }, 118 },