@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" />
149 lines (144 loc) • 4.5 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const fpiTgFactorTools = require('fpi-tg-factor-tools');
const dayjs = require('dayjs');
require('../common/BasicEcharts/index.js');
const index = require('./api/index.js');
const index_vue_vue_type_script_setup_true_lang = require('../common/BasicEcharts/index.vue.js');
require('../common/BasicEcharts/index.vue2.js');
const clsfix = "dv-aims-cieq-contributio-ratio";
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "index",
props: {
apiParams: { default: () => ({
time: dayjs().subtract(1, "h").valueOf(),
code: "0101000000",
codeType: "grid"
}) },
showCieq: { type: Boolean, default: false }
},
setup(__props) {
const props = __props;
const chartsFullOptions = vue.ref({ options: null });
const generateOption = (list, cieq) => {
return {
options: {
title: [
{
show: props.showCieq,
text: `{cieq|${cieq}}`,
top: "62px",
left: "center",
textStyle: {
rich: {
cieq: {
fontSize: 16,
color: "#fff"
}
}
}
}
],
grid: {
left: 0,
right: 0
},
legend: {
show: true,
bottom: -4,
itemGap: 10,
textStyle: {
color: "var(--dv-color-text-primary)",
fontSize: "var(--dv-text-body2)"
},
icon: "circle",
itemWidth: 12,
itemHeight: 12
},
tooltip: {
trigger: "item",
padding: 8,
formatter: (params) => {
return `${params.marker} ${params.name} ${params.data.value2} ${params.value}%`;
},
background: "rgba(1, 11, 18, 0.6)"
},
series: [
{
type: "pie",
radius: props.showCieq ? ["28%", "60%"] : "60%",
center: ["50%", "44%"],
data: list,
label: {
position: "outside",
color: "var(--dv-color-text-primary)",
overflow: "none",
formatter: (params) => {
const { name, value, value2 } = params.data;
return `${name} ${value2} ${value}%`;
},
fontSize: "var(--dv-text-number1)",
fontFamily: "var(--dv-font-family-number)"
}
}
]
}
};
};
const fetchData = () => {
const colors = [
"#0062FF",
"#0AAEFF",
"#2AC94F",
"#FF792E",
"#F84439",
"#FFB443"
];
index.getAirQualityStatis(props.apiParams).then((res) => {
if (res.data && res.data.CIEQ) {
const data1 = res.data.CIEQ.CIEQYearValueRate;
const data2 = res.data.CIEQ.CIEQYearValue;
const cieq = res.data.CIEQ.CIEQYearValue.cieq;
const list = fpiTgFactorTools.BASE_FACTOR.filter((item) => item.code !== "aqi").map((item, index) => {
const key = `V_ICIEQ_${item.key}`;
const value1 = data1[key] ?? 0;
const value2 = data2[key] ?? 0;
return {
name: item.name,
code: item.code,
value: value1,
value2,
itemStyle: {
color: colors[index]
}
};
});
chartsFullOptions.value = generateOption(list, cieq);
}
});
};
vue.onMounted(() => {
fetchData();
});
vue.watch(() => props.apiParams, () => {
fetchData();
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(`${clsfix}-container`)
}, [
vue.createElementVNode("div", {
class: vue.normalizeClass(`${clsfix}-echarts`)
}, [
vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang.default), {
height: "100%",
"full-options": chartsFullOptions.value,
loading: false
}, null, 8, ["full-options"])
], 2)
], 2);
};
}
});
exports.default = _sfc_main;