UNPKG

@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" />

174 lines (171 loc) 4.71 kB
import { defineComponent, ref, toRefs, watch, nextTick, openBlock, createElementBlock, createElementVNode, createVNode, unref } from 'vue'; import echarts from '../../utils/echarts/index.mjs'; import _sfc_main$1 from '../../utils/echarts/BaseECharts.vue.mjs'; import { getNPTrendChange } from './api/index.mjs'; const _hoisted_1 = { class: "dv-wgms-n-p-trend-change" }; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "DvWgmsNPTrendChange", title: "氮磷比趋势变化" }, __name: "index", props: { height: { default: "200px" }, params: { default: () => { return { dataType: "1", startTime: 1694016e6, endTime: 1694620799999, siteCode: "YYALGAE024", stationCode: "1", timeType: "day" }; } }, data: { default: null } }, setup(__props, { expose: __expose }) { const props = __props; const state = { chartRef: null // 图表实例 }; const option = ref(void 0); const { chartRef } = toRefs(state); watch([ () => props.params, () => props.data, () => props.isLazy ], async () => { await nextTick(() => { !props.isLazy && initChart(); }); }, { deep: true, immediate: true }); async function initChart() { let data; if (!props.data) { const res = await getNPTrendChange(props.params); data = res?.data; } else { data = props.data; } const preList = data?.percent || []; const xData = data?.time || []; const NPList = preList.map((item) => { return item === null ? null : item * 100; }); option.value = getChartOptions(xData, NPList, echarts); } const getChartOptions = (xData, data, echarts2) => { return { title: { show: true, text: "N/P(100%)", textAlign: "left", left: 10, top: 14, textStyle: { color: "var(--dv-color-text-secondary)", fontSize: "var(--dv-text-number2)", fontFamily: "var(--dv-font-family-number)" } }, tooltip: { trigger: "axis", axisPointer: { type: "line" // 默认为直线,可选为:'line' | 'shadow' } }, grid: { top: 50, left: 10, right: "1%", bottom: 10, containLabel: true }, xAxis: [ { type: "category", data: xData, axisLine: { show: false }, axisLabel: { textStyle: { fontFamily: "var(--dv-font-family-number)", fontSize: "var(--dv-text-number2)", color: "var(--dv-color-text-primary)" } }, axisTick: { show: false, interval: 24 } } ], yAxis: [ { type: "value", name: "", axisLabel: { textStyle: { fontFamily: "var(--dv-font-family-number)", fontSize: "var(--dv-text-number2)", color: "var(--dv-color-text-secondary)" } }, axisLine: { show: false }, splitArea: { show: false }, splitLine: { show: true, lineStyle: { color: "var(--dv-color-fill-lighter)" } }, axisTick: { show: false } } ], series: [ { name: "氮磷比趋势变化", type: "line", symbolSize: 0, smooth: true, lineStyle: { color: "var(--dv-color-index)" }, areaStyle: { normal: { color: new echarts2.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "var(--dv-color-index)" }, { offset: 1, color: "rgba(71,229,229,0.06)" } ]) } }, data } ] }; }; __expose({ reload: initChart }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", { id: "chart", ref_key: "chartRef", ref: chartRef, class: "chart" }, [ createVNode(_sfc_main$1, { options: unref(option) }, null, 8, ["options"]) ], 512) ]); }; } }); export { _sfc_main as default };