1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <script lang="ts" setup>
- import { onMounted, ref, Ref } from 'vue';
- import { useECharts } from '@/hooks/web/useECharts';
- import { getReqChartBy30 } from '@/api/aigc/statictic';
- const chartRef = ref<HTMLDivElement | null>(null);
- const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
- onMounted(async () => {
- const data = await getReqChartBy30();
- const xData: any = [];
- const yData: any = [];
- data.forEach((i: any) => {
- xData.push(i.date);
- yData.push(i.tokens);
- });
- setOptions({
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- lineStyle: {
- width: 1,
- color: '#019680',
- },
- },
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: xData,
- splitLine: {
- show: true,
- lineStyle: {
- width: 1,
- type: 'solid',
- color: 'rgba(226,226,226,0.5)',
- },
- },
- axisTick: {
- show: false,
- },
- },
- yAxis: [
- {
- type: 'value',
- splitNumber: 4,
- axisTick: {
- show: false,
- },
- splitArea: {
- show: true,
- areaStyle: {
- color: ['rgba(255,255,255,0.2)', 'rgba(226,226,226,0.2)'],
- },
- },
- },
- ],
- grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
- series: [
- {
- smooth: true,
- data: yData,
- type: 'line',
- areaStyle: {},
- itemStyle: {
- color: '#5ab1ef',
- },
- },
- ],
- });
- });
- </script>
- <template>
- <div>
- <h3 class="my-2 mb-6 text-lg">近30天请求汇总</h3>
- <div ref="chartRef" class="w-full h-60"></div>
- </div>
- </template>
|