| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <template>
- <div ref="chartDom" class="charts"></div>
- </template>
- <script setup>
- import { onMounted, ref } from "vue";
- import * as echarts from "echarts";
- import { barOption } from "./option/barOption.js";
- const props = defineProps ({
- styleName: {
- type: String,
- default: "styleName1",
- },
- });
- let chartDom = ref(null);
- let myChart = null;
- const options = ref(null);
- const initData = () => {
- barOption[props.styleName].xAxis.data = ["正常", "较大", "异常"];
- barOption[props.styleName].series[0].data = [33, 41, 43];
- options.value = barOption[props.styleName];
- myChart.setOption(options.value);
- };
- onMounted(() => {
- myChart = echarts.init(chartDom.value);
- initData();
- });
- </script>
- <style lang="scss" scoped>
- .charts {
- width: 100%;
- height: 100%;
- }
- </style>
|