配置
- 配置完成后点击,导出配置,一般为
json 文件,然后放置在Vue项目中assets 中的自定义目录
使用
import myTheme from "@/assets/echarts/shine.project.json";
echarts.registerTheme("mytheme", myTheme.theme);
var myChart = echarts.init(main.value, "mytheme");
<script lang="ts" setup>
import { ref, onMounted, onUpdated } from "vue";
import * as echarts from "echarts";
import { storeToRefs } from "pinia";
import useGNSSArimaStore from "@/store/modules/analyse/useGNSSArimaStore";
import HeXingTuFenXi from "./HeXingTuFenXi.vue";
const main = ref();
const useGNSSArima = useGNSSArimaStore();
const { e_name, y_data, x_data, h_data } = storeToRefs(useGNSSArima);
function init() {
var myChart = echarts.init(main.value);
myChart.showLoading({
text: "loading",
color: "#c23531",
textColor: "#000",
maskColor: "rgba(255, 255, 255, 0.2)",
zlevel: 0,
});
setTimeout(() => {
myChart.hideLoading();
myChart.setOption(option);
}, 1000);
type EChartsOption = echarts.EChartsOption;
var option: EChartsOption;
option = {
legend: {},
title: [
{
text: e_name?.value + "-近2周数据分布情况",
left: "5%",
},
{
text: "upper: Q3 + 1.5 * IQR \nlower: Q1 - 1.5 * IQR",
borderColor: "#999",
borderWidth: 1,
textStyle: {
fontWeight: "normal",
fontSize: 14,
lineHeight: 20,
},
left: "10%",
top: "90%",
},
],
dataset: [
{
source: [
x_data?.value?.length == 14 ? [] : x_data?.value?.slice(-14,) as any,
y_data?.value?.length == 14 ? [] : y_data?.value?.slice(-14,) as any,
h_data?.value?.length == 14 ? [] : h_data?.value?.slice(-14,) as any,
],
},
{
transform: {
type: "boxplot",
config: { itemNameFormatter: "{value}" },
},
},
{
fromDatasetIndex: 1,
fromTransformResult: 1,
},
],
tooltip: {
trigger: "item",
axisPointer: {
type: "shadow",
},
},
grid: {
left: "10%",
right: "10%",
bottom: "15%",
},
xAxis: {
type: "category",
boundaryGap: true,
nameGap: 30,
axisLabel: {
formatter: function (value: number) {
return ["X方向", "Y方向", "Z方向"][value];
},
show: true,
color: "black",
},
splitLine: {
lineStyle: {
},
},
axisLine: {
show: true,
lineStyle: {
width: 1,
color: "black",
},
},
axisTick: {
show: true,
},
},
yAxis: {
type: "value",
splitArea: {
show: true,
},
axisLabel: {
show: true,
interval: "auto",
},
splitLine: {
show: true,
lineStyle: {
},
},
axisLine: {
show: true,
lineStyle: {
width: 1,
color: "black",
},
},
},
series: [
{
name: "boxplot",
type: "boxplot",
datasetIndex: 1,
boxWidth: [90, 100],
tooltip: {
formatter: function (param: any) {
return [
e_name?.value + "-" + ["X方向", "Y方向", "Z方向"][param.name],
"最高限度: " + param.data[5],
"上四分位: " + param.data[4],
"中四分位: " + param.data[3],
"下四分位: " + param.data[2],
"最低限度: " + param.data[1],
].join("<br/>");
},
},
},
{
name: "outlier",
type: "scatter",
datasetIndex: 2,
},
],
};
option && myChart.setOption(option);
window.onresize = function () {
myChart.resize();
};
}
onMounted(() => {
init();
});
onUpdated(() => {
init();
});
</script>
<template>
<div class="flex justify-center items-center w-full h-full">
<p v-show="false">{{ e_name }}</p>
<div class="w-1/2 h-full">
<div ref="main" style="width: 100%; height: 100%"></div>
</div>
<div class="w-1/2 h-full">
<HeXingTuFenXi></HeXingTuFenXi>
</div>
</div>
</template>
<style scoped></style>
|