@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" />
240 lines (235 loc) • 7.12 kB
JavaScript
'use strict';
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const BaseECharts_vue_vue_type_script_setup_true_lang = require('../../utils/echarts/BaseECharts.vue.js');
const index = require('./api/index.js');
const _hoisted_1 = { class: "dv-wgms-factor-trend-comparison" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{
name: "DvWgmsFactorTrendComparison",
title: "要素趋势对比"
},
__name: "index",
props: {
height: { default: "200px" },
params: { default: () => {
return {
beginTime: 1694016e6,
endTime: 1694620799999,
factor: "64",
siteCode: "YYALGAE024",
siteId: "2399",
stationCode: "1",
timeType: "day"
};
} },
data: { default: null }
},
setup(__props, { expose: __expose }) {
const props = __props;
const option = vue.ref(void 0);
const state = {
factorMap: [],
seriesData: [],
chartRef: null
// 图表实例
};
const { chartRef } = vue.toRefs(state);
vue.watch([() => props.params, () => props.data, () => props.isLazy], async () => {
await vue.nextTick(() => {
!props.isLazy && initChart();
});
}, { deep: true, immediate: true });
const getChartData = async () => {
return await index.getTrendComparisonData(props.params);
};
const initChart = async () => {
let xData = [];
let data = [];
if (!props.data) {
const res = await getChartData();
data = res?.data || [];
} else {
data = props.data || [];
}
data.forEach((item) => {
const timesList = item.factorTimeDataList.map((item2) => item2.time);
const valueList = item.factorTimeDataList.map((item2) => item2.value);
xData = timesList.map((item2) => item2);
const obj = {
name: item.factorName,
type: "line",
symbolSize: 0,
yAxisIndex: item.factorCode === "w01016" ? 1 : item.factorCode === "w01010" ? 2 : 0,
data: valueList.map((item2) => item2 ?? null)
};
state.seriesData.push(obj);
});
await vue.nextTick(async () => {
option.value = getChartOptions(xData, state.seriesData);
});
};
const getChartOptions = (xData, seriesData) => {
return {
tooltip: {
trigger: "axis",
axisPointer: {
type: "line"
// 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
show: true,
type: "scroll",
itemWidth: 12,
itemHeight: 12,
icon: "circle",
bottom: 10,
textStyle: {
color: "var(--dv-color-text-primary)",
fontSize: "var(--dv-text-body2)"
}
},
grid: {
top: 60,
left: "15%",
right: 35,
bottom: 40,
containLabel: true
},
color: ["#2AC94F", "#FFE200", "#FF99C3", "#00FFFD", "#ff99c3", "#00fffd", "#ff7815", "#ef33ff"],
xAxis: [
{
type: "category",
data: xData,
boundaryGap: false,
axisLine: {
show: true,
lineStyle: {
color: "var(--dv-color-fill-lighter)"
}
},
axisLabel: {
textStyle: {
fontSize: "var(--dv-text-number2)",
fontFamily: "var(--dv-font-family-number)",
color: "var(--dv-color-text-primary)"
}
},
axisTick: {
show: false,
interval: 24
}
}
],
yAxis: [
{
name: "因子值\n(mg/L)",
nameTextStyle: {
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-body2)",
align: "center",
padding: [0, 0, 0, 0]
},
type: "value",
offset: 60,
axisLabel: {
formatter: "{value}",
textStyle: {
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-number2)",
fontFamily: "var(--dv-font-family-number)",
align: "center",
padding: [0, 0, 0, 5]
}
},
splitArea: {
show: false
},
splitLine: {
show: true,
lineStyle: {
color: "var(--dv-color-fill-lighter)"
}
},
axisTick: { show: false },
axisPointer: {
snap: true
}
},
{
name: "叶绿素a\n(μg/L)",
nameTextStyle: {
align: "center",
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-body2)",
padding: [0, 0, 0, 0]
},
type: "value",
position: "left",
offset: 10,
axisLabel: {
formatter: "{value}",
textStyle: {
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-number2)",
fontFamily: "var(--dv-font-family-number)",
align: "center"
},
padding: [0, 0, 0, 0]
},
splitLine: { show: false },
axisTick: { show: false },
axisPointer: {
snap: true
}
},
{
name: "水温\n(℃)",
nameTextStyle: {
align: "center",
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-body2)",
padding: [0, 0, 0, 20]
},
type: "value",
position: "right",
offset: 10,
axisLabel: {
formatter: "{value}",
textStyle: {
color: "var(--dv-color-text-secondary)",
fontSize: "var(--dv-text-number2)",
fontFamily: "var(--dv-font-family-number)",
align: "center"
},
padding: [0, 0, 0, 20]
},
splitLine: { show: false },
axisTick: { show: false },
axisPointer: {
snap: true
}
}
],
series: seriesData
};
};
__expose({
reload: initChart
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
vue.createElementVNode("div", {
id: "chart",
ref_key: "chartRef",
ref: chartRef,
class: "chart"
}, [
vue.createVNode(BaseECharts_vue_vue_type_script_setup_true_lang.default, { options: vue.unref(option) }, null, 8, ["options"])
], 512)
]);
};
}
});
exports.default = _sfc_main;