|
@@ -73,7 +73,7 @@
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
import titleContent from './TitleContent.vue';
|
|
|
import * as echarts from 'echarts';
|
|
|
-import { getDataByArea } from '@/service/api/mapRequest';
|
|
|
+import { getDataByArea, getHistogramData } from '@/service/api/mapRequest';
|
|
|
import { stackRightOptions, stackLeftOptions } from '@/utils/chartsOptions.js';
|
|
|
const partitionData = ref({});
|
|
|
|
|
@@ -85,6 +85,74 @@ const initChart = (chartDom, option) => {
|
|
|
option && myChart.setOption(option);
|
|
|
};
|
|
|
|
|
|
+const getBarData = async () => {
|
|
|
+ try {
|
|
|
+ const res = await getHistogramData();
|
|
|
+ if (res.code == 200) {
|
|
|
+ const data = res?.data || [];
|
|
|
+ const dateArr = Object.keys(data);
|
|
|
+ const data1 = dateArr.map((item) => {
|
|
|
+ return { date: item, num: 0 };
|
|
|
+ });
|
|
|
+ const data2 = dateArr.map((item) => {
|
|
|
+ return { date: item, num: 0 };
|
|
|
+ });
|
|
|
+ const data3 = dateArr.map((item) => {
|
|
|
+ return { date: item, num: 0 };
|
|
|
+ });
|
|
|
+ const data4 = dateArr.map((item) => {
|
|
|
+ return { date: item, num: 0 };
|
|
|
+ });
|
|
|
+ Object.values(data).forEach((item) => {
|
|
|
+ item.forEach((element) => {
|
|
|
+ if (element.type == '1') {
|
|
|
+ data1.forEach((data) => {
|
|
|
+ if (element.month == data.date) {
|
|
|
+ data.num = element.num;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (element.type == '2') {
|
|
|
+ data2.forEach((data) => {
|
|
|
+ if (element.month == data.date) {
|
|
|
+ data.num = element.num;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (element.type == '3') {
|
|
|
+ data3.forEach((data) => {
|
|
|
+ if (element.month == data.date) {
|
|
|
+ data.num = element.num;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (element.type == '4') {
|
|
|
+ data4.forEach((data) => {
|
|
|
+ if (element.month == data.date) {
|
|
|
+ data.num = element.num;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ const yAxisData = {
|
|
|
+ data1: Object.values(data1).map((item) => item.num),
|
|
|
+ data2: Object.values(data2).map((item) => item.num),
|
|
|
+ data3: Object.values(data3).map((item) => item.num),
|
|
|
+ data4: Object.values(data4).map((item) => item.num)
|
|
|
+ };
|
|
|
+ const line = yAxisData.data1.map((item, index) => {
|
|
|
+ return (
|
|
|
+ (item + yAxisData.data2[index] + yAxisData.data3[index] + yAxisData.data4[index]) / 4
|
|
|
+ );
|
|
|
+ });
|
|
|
+ yAxisData.line = line;
|
|
|
+ initChart(rightChartId.value, stackRightOptions(dateArr, yAxisData));
|
|
|
+ initChart(leftChartId.value, stackLeftOptions(dateArr, yAxisData));
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
//分区看板
|
|
|
const getLeftChartData = async () => {
|
|
|
try {
|
|
@@ -139,23 +207,7 @@ const getSum = (numArr) => {
|
|
|
};
|
|
|
onMounted(() => {
|
|
|
getLeftChartData();
|
|
|
- let xAxisData = [];
|
|
|
- const yAxisData = {
|
|
|
- data1: [],
|
|
|
- data2: [],
|
|
|
- data3: [],
|
|
|
- data4: []
|
|
|
- };
|
|
|
-
|
|
|
- for (let i = 0; i < 10; i++) {
|
|
|
- xAxisData.push('202' + i);
|
|
|
- yAxisData.data1.push(+(Math.random() * 2).toFixed(2));
|
|
|
- yAxisData.data2.push(+(Math.random() * 5).toFixed(2));
|
|
|
- yAxisData.data3.push(+(Math.random() + 0.3).toFixed(2));
|
|
|
- yAxisData.data4.push(+Math.random().toFixed(2));
|
|
|
- }
|
|
|
- initChart(rightChartId.value, stackRightOptions(xAxisData, yAxisData));
|
|
|
- initChart(leftChartId.value, stackLeftOptions(xAxisData, yAxisData));
|
|
|
+ getBarData();
|
|
|
});
|
|
|
</script>
|
|
|
|