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

178 lines (173 loc) 4.85 kB
'use strict'; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const vue = require('vue'); const index$1 = require('../../utils/echarts/index.js'); 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-n-p-trend-change" }; const _sfc_main = /* @__PURE__ */ vue.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 = vue.ref(void 0); const { chartRef } = vue.toRefs(state); vue.watch([ () => props.params, () => props.data, () => props.isLazy ], async () => { await vue.nextTick(() => { !props.isLazy && initChart(); }); }, { deep: true, immediate: true }); async function initChart() { let data; if (!props.data) { const res = await index.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, index$1.default); } 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 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;