| | |
| | | import { onMounted, ref, watchEffect, nextTick, onBeforeUnmount } from "vue"; |
| | | import * as echarts from 'echarts'; |
| | | import baseChart from "./BaseChart.vue"; |
| | | import { toFixed } from '@/utils/toFixed.js'; |
| | | |
| | | const chart = ref(null); |
| | | const props = defineProps({ |
| | |
| | | unit: { |
| | | type: String, |
| | | default: '' |
| | | } |
| | | }, |
| | | barW: { |
| | | type: [Number, String], |
| | | default: 60, |
| | | }, |
| | | }); |
| | | |
| | | const barWidth = 60; |
| | | |
| | | function createLinearColor(color) { |
| | | return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ |
| | |
| | | |
| | | function getMax(data) { |
| | | let max = Math.max.apply(null, data) * 1.2; |
| | | return max || 1; |
| | | return toFixed(max, 1) || 1; |
| | | } |
| | | |
| | | |
| | | function getOptions(xLabels, datas) { |
| | | xLabels = xLabels || []; |
| | | datas = datas || []; |
| | | let barWidth = props.barW; |
| | | const option = { |
| | | // title: { |
| | | // text: props.title, |
| | |
| | | grid: { |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | bottom: '8%', |
| | | top: 30, |
| | | containLabel: true |
| | | }, |
| | |
| | | return chart_instance; |
| | | } |
| | | |
| | | function getDataURL() { |
| | | return chart.value.getDataURL(); |
| | | } |
| | | |
| | | defineExpose({ |
| | | getChart, |
| | | getDataURL, |
| | | updateChart |
| | | }); |
| | | |