vehicle-monitor/src/views/business-supervision/charts/contentBottom.ts

72 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-03-08 21:57:09 +08:00
import 'echarts/lib/component/dataZoom';
import type { EChartsOption } from 'echarts';
import { type Ref, ref } from 'vue';
import echarts from '@/plugins/echarts';
2025-03-15 16:38:44 +08:00
import { debounceChart, graphicLinearGradient } from '@/utils/chart';
2025-03-08 21:57:09 +08:00
2025-03-15 16:38:44 +08:00
let myChart = null;
2025-03-08 21:57:09 +08:00
const option = ref<EChartsOption>();
option.value = {
tooltip: {
trigger: 'axis',
2025-03-08 23:44:47 +08:00
axisPointer: { type: 'shadow', shadowStyle: { shadowColor: '#66FFFF', shadowBlur: 10 } },
2025-03-08 21:57:09 +08:00
},
grid: { top: '9%', right: '0%', left: '6%', bottom: '9%', containLabel: false },
xAxis: [
{
type: 'category',
data: [
'2021.01',
'2021.02',
'2021.03',
'2021.04',
'2021.05',
'2021.06',
'2021.07',
'2021.08',
'2021.09',
'2021.10',
'2021.11',
'2021.12',
],
axisTick: { alignWithLabel: true },
},
],
yAxis: [
{
type: 'value',
splitLine: {
show: true,
lineStyle: { type: 'solid', color: '#707070', width: 2 },
},
},
],
series: [
{
name: 'Direct',
type: 'bar',
barWidth: '40%',
2025-03-15 16:38:44 +08:00
itemStyle: { color: graphicLinearGradient('#00CCD2', '#00A2FF') },
2025-03-13 18:39:39 +08:00
// emphasis: {
// shadowBlur: 10, // 取消阴影模糊
// shadowColor: '#000', // 取消阴影颜色
// },
2025-03-08 21:57:09 +08:00
label: { show: true, position: 'top', color: '#fff', fontSize: 14 },
data: [10, 52, 200, 334, 390, 330, 220, 500, 482, 499, 999, 444],
},
],
};
export const renderEcharts = (element: Ref<HTMLDivElement>) => {
2025-03-15 16:38:44 +08:00
myChart = echarts.init(element.value, null, {
2025-03-08 21:57:09 +08:00
renderer: 'svg',
devicePixelRatio: window.devicePixelRatio,
});
2025-03-12 09:42:48 +08:00
debounceChart(myChart);
2025-03-08 21:57:09 +08:00
myChart.setOption(option.value);
};