@ued_fpi/data-visual
Version:
<br /> <br /> <div style="text-align:center"> <b style="font-size:30px">@ued_fpi/data-visual</b> <p>基于Vite4+TypeScript的Vue3大屏组件库开发框架</p> <img style="display:inline" src="https://img.shields.io/npm/v/@ued_fpi/data-visual" />
198 lines (193 loc) • 5.33 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const dayjs = require('dayjs');
const core = require('@vueuse/core');
const request = require('../../service/request.js');
const Echarts_vue_vue_type_script_setup_true_lang = require('../common/Echarts.vue.js');
require('../common/Echarts.vue2.js');
const hooks = require('../../utils/hooks.js');
const _hoisted_1 = { class: "dv-ipes-vehicle-trend" };
const __default__ = {
name: "DvIpesVehicleTrend",
title: "近30日进/出场车辆数量变化"
};
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: {
// 时间类型,day-日,返回每小时的统计数据,month-月,返回每天的统计数据,year-年,返回每月的统计数据
flowTimeType: {
type: String,
default: "month"
},
// 停车场id,指定停车场统计
parkId: {
type: String,
default: ""
},
parkType: {
type: String,
default: "tcclx_2"
},
// 开始时间
beginTime: {
type: Number,
default: dayjs().subtract(30, "d").valueOf()
},
// 结束时间
endTime: {
type: Number,
default: Date.now()
},
// 高度
height: {
type: String,
default: "132px"
},
url: {
type: String,
default: "/ipes-pcip-server/api/v1/statistical/flow-car/line"
}
},
setup(__props) {
const props = __props;
vue.ref({
value: 0,
main: ""
});
const xlabelEl = vue.ref(null);
core.useCssVar("--dv-color-text-primary", xlabelEl);
const ylabelEl = vue.ref(null);
core.useCssVar("--dv-color-text-secondary", ylabelEl);
const splitLineEl = vue.ref(null);
core.useCssVar("--dv-color-border-light", splitLineEl);
const chartOption = vue.reactive({
options: {
tooltip: {
show: true,
trigger: "axis"
},
grid: {
top: "40px",
left: "40px",
right: "20px",
bottom: "30px"
},
legend: {
show: true,
top: 12,
itemGap: 24,
textStyle: {
color: "var(--dv-color-text-primary)",
fontSize: "var(--ipes-dv-text-body2)"
},
itemWidth: 16,
itemHeight: 8
},
xAxis: {
type: "category",
axisLabel: {
color: "var(--dv-color-text-primary)"
},
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: "var(--dv-color-border-light)"
}
},
data: []
},
yAxis: {
type: "value",
axisLabel: {
color: "var(--dv-color-text-secondary)"
},
splitLine: {
lineStyle: {
color: "var(--dv-color-border-light)"
},
show: true
}
},
series: [
{
data: [],
type: "line",
name: "进场车辆",
itemStyle: {
color: "#0AAEFF",
lineStyle: {
color: "#0AAEFF",
borderWidth: 8
}
}
},
{
data: [],
type: "line",
name: "出场车辆",
itemStyle: {
color: "#FFB443",
lineStyle: {
color: "#FFB443",
borderWidth: 8
}
}
}
]
}
});
async function getData() {
try {
const { flowTimeType, parkId, beginTime, endTime, parkType, url } = props;
const res = await request.default({
method: "get",
url,
params: {
parkType,
flowTimeType,
parkId,
beginTime,
endTime
}
});
const data = res?.data?.map((item) => {
return {
time: dayjs(item.time).format("MM-DD"),
inNum: item.inNum,
outNum: item.outNum
};
});
setOptions(data);
} catch (error) {
console.log(error);
}
}
function setOptions(data) {
const inMaxData = data.map((ele) => ele.inNum);
const outMaxData = data.map((ele) => ele.outNum);
const maxValue = Math.max(...inMaxData, ...outMaxData);
const maxLenth = isNaN(maxValue) ? 0 : maxValue.toString().length;
chartOption.options.xAxis.data = data.map((ele) => ele.time);
chartOption.options.series[0].data = inMaxData;
chartOption.options.series[1].data = outMaxData;
chartOption.options.grid.left = maxLenth < 4 ? "40px" : `${maxLenth * 12}px`;
}
vue.onMounted(() => {
getData();
});
hooks.setIntervalData(getData);
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createVNode(Echarts_vue_vue_type_script_setup_true_lang.default, {
"full-options": vue.unref(chartOption),
loading: false,
height: __props.height
}, null, 8, ["full-options", "height"])
]);
};
}
});
exports.default = _sfc_main;