123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- import * as uecharts from "echarts";
- import { reactive } from "vue";
- import {
- StatisticsParams,
- getSceneStatistics,
- getCaseStatistics,
- getCameraTypeStatistics,
- getCaseTimeStatistics,
- getCasePlaceStatistics,
- getCaseReasonStatistics,
- } from "@/store/statistics";
- export const echarts = uecharts;
- export type { EChartsType } from "echarts";
- export type ConfigItem = {
- title: string;
- data: any;
- };
- export const statisticsConfigs: ConfigItem[] = reactive([
- {
- title: "火灾场景数据采集统计",
- data: {
- tooltip: {
- trigger: "item",
- },
- legend: {
- orient: "vertical",
- left: "right",
- type: "scroll",
- },
- series: [
- {
- itemStyle: {
- borderColor: "#fff",
- borderWidth: 3,
- },
- name: "火灾场景数据采集统计",
- type: "pie",
- label: {
- formatter: "{c}个",
- rich: {
- time: {
- fontSize: 10,
- color: "#999",
- },
- },
- },
- radius: "50%",
- center: ["40%", "50%"],
- data: [],
- },
- ],
- },
- },
- {
- title: "采集设备类型统计",
- data: {
- tooltip: {
- trigger: "axis",
- },
- xAxis: {
- type: "category",
- data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- label: {
- show: true,
- },
- data: [120, 200, 150, 80, 70, 110, 130],
- type: "bar",
- },
- ],
- },
- },
- {
- title: "火调项目统计",
- data: {
- tooltip: {
- trigger: "item",
- },
- legend: {
- orient: "vertical",
- left: "right",
- type: "scroll",
- // top: "center",
- },
- series: [
- {
- itemStyle: {
- borderColor: "#fff",
- borderWidth: 3,
- },
- name: "火调项目统计",
- type: "pie",
- label: {
- formatter: "{d}%",
- rich: {
- time: {
- fontSize: 10,
- color: "#999",
- },
- },
- },
- radius: "50%",
- center: ["40%", "50%"],
- data: [],
- },
- ],
- },
- },
- {
- title: "火灾趋势分析",
- data: {
- tooltip: {
- trigger: "axis",
- },
- xAxis: {
- type: "category",
- data: [],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- label: {
- show: true,
- },
- data: [],
- type: "line",
- },
- ],
- },
- },
- {
- title: "起火场所统计",
- data: {
- tooltip: {
- trigger: "axis",
- },
- xAxis: {
- type: "category",
- data: [],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- label: {
- show: true,
- },
- data: [],
- type: "bar",
- },
- ],
- },
- },
- {
- title: "火灾原因统计",
- data: {
- tooltip: {
- trigger: "axis",
- },
- xAxis: {
- type: "category",
- data: [],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- label: {
- show: true,
- },
- data: [],
- type: "bar",
- },
- ],
- },
- },
- ]);
- const numRotate = 8;
- const numSlide = 20;
- export const updateParams = async (params: StatisticsParams) => {
- const statisticsItemsArray = await Promise.all([
- getSceneStatistics(params),
- getCameraTypeStatistics(params),
- getCaseStatistics(params),
- getCaseTimeStatistics(params),
- getCasePlaceStatistics(params),
- getCaseReasonStatistics(params),
- ]);
- const radiusNds = [0, 2];
- for (let ndx = 0; ndx < statisticsConfigs.length; ndx++) {
- let items = statisticsItemsArray[ndx];
- if (radiusNds.includes(ndx)) {
- statisticsConfigs[ndx].data.series![0].data = items.map((item) => ({
- value: item.dataCount,
- name: item.groupKey,
- }));
- console.log(statisticsConfigs[ndx].data);
- } else {
- statisticsConfigs[ndx].data.xAxis.data = items.map(
- (item) => item.groupKey
- );
- statisticsConfigs[ndx].data.xAxis.axisLabel = {
- interval: "auto",
- rotate: 0,
- };
- statisticsConfigs[ndx].data.dataZoom = [
- {
- id: 1,
- type: "inside",
- start: 0,
- end: 100,
- disabled: true,
- zoomLock: true,
- show: false,
- },
- {
- id: 2,
- start: 0,
- end: 100,
- disabled: true,
- zoomLock: true,
- show: false,
- },
- ];
- if (items.length > numRotate && items.length < numSlide) {
- statisticsConfigs[ndx].data.xAxis.axisLabel = {
- interval: 0,
- rotate: 30,
- };
- } else if (items.length >= numSlide) {
- statisticsConfigs[ndx].data.dataZoom = [
- {
- id: 1,
- type: "inside",
- start: 0,
- end: 100,
- disabled: false,
- zoomLock: false,
- show: true,
- },
- {
- id: 2,
- start: 0,
- end: 100,
- disabled: false,
- zoomLock: false,
- show: true,
- },
- ];
- }
- statisticsConfigs[ndx].data.series![0].data = items.map(
- (item) => item.dataCount
- );
- }
- }
- };
|