update line chart

This commit is contained in:
lb 2023-05-10 15:31:34 +08:00
parent 405672842a
commit c9c920fdb5
4 changed files with 21792 additions and 3773 deletions

17787
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
}, },
"dependencies": { "dependencies": {
"core-js": "^3.8.3", "core-js": "^3.8.3",
"echarts": "^5.4.2",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",

View File

@ -3,7 +3,7 @@
<div class="line-chart__wrapper"> <div class="line-chart__wrapper">
<div class="line-chart__custom-legend flex"> <div class="line-chart__custom-legend flex">
<span>产线1 - 产线5</span> <span>产线1 - 产线5</span>
<ul style="margin-left: 8px; padding-left: 8px;" class="flex"> <ul style="margin-left: 8px; padding-left: 8px" class="flex">
<li>产线1</li> <li>产线1</li>
<li>产线2</li> <li>产线2</li>
<li>产线3</li> <li>产线3</li>
@ -11,11 +11,34 @@
<li>产线5</li> <li>产线5</li>
</ul> </ul>
</div> </div>
<div id="line-chart"></div> <div id="line-chart" style="width: 100%; height: 100%"></div>
</div> </div>
</template> </template>
<script> <script>
import * as echarts from "echarts/core";
import { LineChart } from "echarts/charts";
import {
TitleComponent,
TooltipComponent,
GridComponent,
} from "echarts/components";
import { LabelLayout, UniversalTransition } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([
TitleComponent,
TooltipComponent,
GridComponent,
LineChart,
LabelLayout,
UniversalTransition,
CanvasRenderer,
]);
export default { export default {
name: "LineChart", name: "LineChart",
props: { props: {
@ -28,6 +51,7 @@ export default {
}, },
data() { data() {
return { return {
chart: null,
colors: [ colors: [
"#18c7f3", "#18c7f3",
"#FFD160", "#FFD160",
@ -41,11 +65,132 @@ export default {
"#19f", "#19f",
"#98f", "#98f",
], ],
data: [],
}; };
}, },
created() {}, mounted() {
mounted() {}, this.init();
methods: {}, },
methods: {
init() {
if (!this.chart)
this.chart = echarts.init(document.getElementById("line-chart"));
this.chart.setOption({
// title: {
// text: "ECharts ",
// },
grid: {
top: 32,
left: 32,
bottom: 24,
right: 12,
},
tooltip: {
trigger: "axis",
axisPointer: {
lineStyle: {
color: "#eee3",
},
},
},
xAxis: {
data: Array(31)
.fill(1)
.map((_, index) => index + 1),
axisLine: {
lineStyle: {
// width: 1,
color: "#5982b2a0",
},
},
axisTick: {
show: false,
},
axisLabel: {
color: "#ffffff",
fontSize: 6,
lineHeight: 1,
},
},
yAxis: {
type: "value",
name: "单位/m³",
nameTextStyle: {
color: "#fff9",
fontSize: 6,
// lineHeight: 6,
// height: 6,
// padding: 0,
align: "right",
},
axisLine: {
show: true,
lineStyle: {
// width: 1,
color: "#5982b2a0",
},
},
axisTick: {
show: false,
},
axisLabel: {
color: "#fff9",
fontSize: 6,
lineHeight: 1,
},
splitLine: {
lineStyle: {
color: "#5982b2a0",
},
},
// data: [100, 200, 300, 400, 500],
},
color: this.colors,
series: Array(5)
.fill(1)
.map((_, index) => ({
name: Math.random(),
type: "line",
symbol: "circle",
symbolSize: 3,
lineStyle: {
width: "1",
},
areaStyle: {
// color: {
// type: "linear",
// x: 0,
// y: 0,
// x2: 0,
// y2: 1,
// colorStops: [
// {
// offset: 0,
// color: this.colors[index]+'66',
// },
// // { offset: 0.3, color: this.colors[index]+'aa' },
// // { offset: 0.35, color: this.colors[index]+'77' },
// // { offset: 1, color: this.colors[index]+'00' },
// { offset: .5, color: 'transparent' },
// ],
// },
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: this.colors[index] + "44" },
{ offset: 1, color: "transparent" },
]),
},
data: Array(31)
.fill(1)
.map(() => {
let v = Math.floor(Math.random() * 5000);
while (v < 3000) v = Math.floor(Math.random() * 5000);
return v;
}),
})),
});
},
initData() {},
},
}; };
</script> </script>
@ -81,16 +226,47 @@ li {
} }
li::before { li::before {
content: ''; content: "";
position: absolute; position: absolute;
top: 1px; top: 2px;
left: -7px; left: -6px;
width: 6px; width: 4px;
height: 6px; height: 4px;
border-radius: 1px; border-radius: 1px;
background: #eee6; background: #eee6;
} }
li:nth-child(1)::before {
background: #18c7f3;
}
li:nth-child(2)::before {
background: #f31868;
}
li:nth-child(3)::before {
background: #30e89a;
}
li:nth-child(4)::before {
background: #2760ff;
}
li:nth-child(5)::before {
background: #ee3fff;
}
li:nth-child(6)::before {
background: #2f0fff;
}
li:nth-child(7)::before {
background: #800f77;
}
li:nth-child(8)::before {
background: #f77;
}
li:nth-child(9)::before {
background: #19f;
}
li:nth-child(10)::before {
background: #98f;
}
ul { ul {
flex: 1; flex: 1;
width: 144px; width: 144px;

7581
yarn.lock

File diff suppressed because it is too large Load Diff