|
@@ -9,112 +9,105 @@
|
|
|
<script lang="ts" setup>
|
|
|
import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
|
|
|
import * as echarts from "echarts";
|
|
|
+import { weekProductionSchedule } from "@/api/screens";
|
|
|
|
|
|
const chartRef = ref(null);
|
|
|
|
|
|
-var data = [220, 182, 191, 234, 290, 120, 65, 444];
|
|
|
-var barWidth = 20;
|
|
|
-var maxNum = 0;
|
|
|
-for (var i = 0; i < data.length; i++) {
|
|
|
- if (data[i] > maxNum) {
|
|
|
- maxNum = data[i];
|
|
|
- }
|
|
|
-}
|
|
|
+onMounted(async () => {
|
|
|
+ const chart = echarts.init(chartRef.value, "dark");
|
|
|
|
|
|
-const option = {
|
|
|
- backgroundColor: "transparent",
|
|
|
- // grid: {
|
|
|
- // top: "0%",
|
|
|
- // left: "0%",
|
|
|
- // right: "0%",
|
|
|
- // bottom: "0%",
|
|
|
- // },
|
|
|
+ let res: any = await weekProductionSchedule();
|
|
|
|
|
|
- title: {
|
|
|
- text: "百分比柱子",
|
|
|
- show: false,
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- show: false,
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- data: data.map((item, index) => `data ${index}`),
|
|
|
- splitLine: {
|
|
|
+ const maxNum = Math.max.apply(null, res?.data[2]);
|
|
|
+ const barWidth = 20;
|
|
|
+
|
|
|
+ const option = {
|
|
|
+ backgroundColor: "transparent",
|
|
|
+ title: {
|
|
|
+ text: "百分比柱子",
|
|
|
show: false,
|
|
|
},
|
|
|
- axisLabel: {
|
|
|
- textStyle: { fontSize: "80%", color: "#02afff" },
|
|
|
- },
|
|
|
- axisLine: {
|
|
|
+ xAxis: {
|
|
|
show: false,
|
|
|
},
|
|
|
- axisTick: false,
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- type: "bar",
|
|
|
- barWidth: barWidth,
|
|
|
- zlevel: 2,
|
|
|
- data: data.map(function (item) {
|
|
|
- return {
|
|
|
- value: item,
|
|
|
- maxNum: maxNum,
|
|
|
- };
|
|
|
- }),
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- position: "inside",
|
|
|
- // distance: 80,
|
|
|
- align: "center",
|
|
|
- formatter: function (params) {
|
|
|
- // return params.data.realValue;
|
|
|
- var percent =
|
|
|
- Number((params.data.value / params.data.maxNum) * 100).toFixed(2) +
|
|
|
- "%";
|
|
|
- return percent;
|
|
|
- },
|
|
|
- color: "#fff",
|
|
|
- fontSize: 12,
|
|
|
+ yAxis: {
|
|
|
+ data: res?.data[0],
|
|
|
+ splitLine: {
|
|
|
+ show: false,
|
|
|
},
|
|
|
- itemStyle: {
|
|
|
- borderRadius: 10,
|
|
|
- color: new echarts.graphic.LinearGradient(0, 1, 1, 1, [
|
|
|
- { offset: 0, color: "#395CFE" },
|
|
|
- { offset: 1, color: "#2EC7CF" },
|
|
|
- ]),
|
|
|
+ axisLabel: {
|
|
|
+ textStyle: { fontSize: "40%", color: "#02afff" },
|
|
|
},
|
|
|
+ axisLine: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ axisTick: false,
|
|
|
},
|
|
|
- {
|
|
|
- type: "bar",
|
|
|
- barWidth: barWidth,
|
|
|
- barGap: "-100%",
|
|
|
- data: data.map(function (item) {
|
|
|
- return {
|
|
|
- realValue: item,
|
|
|
- value: maxNum,
|
|
|
- };
|
|
|
- }),
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- position: "right",
|
|
|
- distance: 80,
|
|
|
- align: "right",
|
|
|
- formatter: function (params) {
|
|
|
- return params.data.realValue + " 件";
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: "bar",
|
|
|
+ barWidth: barWidth,
|
|
|
+ zlevel: 2,
|
|
|
+ data: res?.data[1].map(function (item, index) {
|
|
|
+ return {
|
|
|
+ value: item,
|
|
|
+ maxNum: res?.data[2][index],
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: "inside",
|
|
|
+ // distance: 80,
|
|
|
+ align: "left",
|
|
|
+ formatter: function (params) {
|
|
|
+ // return params.data.realValue;
|
|
|
+ var percent =
|
|
|
+ Number((params.data.value / params.data.maxNum) * 100).toFixed(
|
|
|
+ 2
|
|
|
+ ) + "%";
|
|
|
+ return percent;
|
|
|
+ },
|
|
|
+ color: "#fff",
|
|
|
+ fontSize: 12,
|
|
|
+ },
|
|
|
+ itemStyle: {
|
|
|
+ borderRadius: 10,
|
|
|
+ color: new echarts.graphic.LinearGradient(0, 1, 1, 1, [
|
|
|
+ { offset: 0, color: "#395CFE" },
|
|
|
+ { offset: 1, color: "#2EC7CF" },
|
|
|
+ ]),
|
|
|
},
|
|
|
- color: "#02afff",
|
|
|
- fontSize: 18,
|
|
|
},
|
|
|
- itemStyle: {
|
|
|
- borderRadius: 10,
|
|
|
- color: "rgba(3,169,244, 0.5)",
|
|
|
+ {
|
|
|
+ type: "bar",
|
|
|
+ barWidth: barWidth,
|
|
|
+ barGap: "-100%",
|
|
|
+ data: res?.data[2].map(function (item, index) {
|
|
|
+ return {
|
|
|
+ maxNum: maxNum,
|
|
|
+ completeNum: res?.data[1][index],
|
|
|
+ value: item,
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: "right",
|
|
|
+ distance: 80,
|
|
|
+ align: "right",
|
|
|
+ formatter: function (params) {
|
|
|
+ return params.data.completeNum + "/" + params.data.value + " 件";
|
|
|
+ },
|
|
|
+ color: "#02afff",
|
|
|
+ fontSize: 18,
|
|
|
+ },
|
|
|
+ itemStyle: {
|
|
|
+ borderRadius: 10,
|
|
|
+ color: "rgba(3,169,244, 0.5)",
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- ],
|
|
|
-};
|
|
|
+ ],
|
|
|
+ };
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- const chart = echarts.init(chartRef.value, "dark");
|
|
|
chart.setOption(option);
|
|
|
});
|
|
|
|