| | |
| | | <template> |
| | | <el-tabs v-model="activeName" class="demo-tabs min-w-[38rem] flex-column" @tab-click="handleClick"> |
| | | <el-tabs v-model="activeName" class="demo-tabs min-w-[38rem] flex-column" @tab-click="handleClick"> |
| | | <el-tab-pane class="h-full" label="Chart" name="first"> |
| | | <el-select class="flex-0 w-36" v-model="selectChartType" @change="selectChartTypeChange"> |
| | | <!-- <el-select class="flex-0 w-36" v-model="selectChartType" @change="selectChartTypeChange"> |
| | | <el-option |
| | | v-for="item in Object.keys(chartTypeMapName)" |
| | | :key="item" |
| | | :value="parseInt(item)" |
| | | :label="chartTypeMapName[item]" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-select> --> |
| | | <div class="flex-auto"> |
| | | <div ref="chartRef" class="h-full"></div> |
| | | </div> |
| | |
| | | import { ChartTypeEnum, chartTypeMapEchart, chartTypeMapName } from '../types'; |
| | | import type { RecordSetValues } from '/@/api/ai/chat'; |
| | | import { dateRegex } from '/@/utils/toolsValidate'; |
| | | import { PATH_ICON, SCATTER_SYMBOL_SIZE, timeDataOptionToContent } from '../common'; |
| | | const activeName = ref('first'); |
| | | const chartRef = ref<HTMLDivElement>(null); |
| | | const selectChartType = ref<ChartTypeEnum>(ChartTypeEnum.Line); |
| | |
| | | type: Object as PropType<RecordSetValues>, |
| | | }, |
| | | }); |
| | | |
| | | |
| | | |
| | | const selectChartTypeChange = () => { |
| | | drawChart(); |
| | |
| | | chartInstance.setOption({ |
| | | grid: { |
| | | // bottom: 120, |
| | | right:'15%', |
| | | bottom: '15%', |
| | | right: '15%', |
| | | bottom: '5%', |
| | | }, |
| | | tooltip: { |
| | | show: true, |
| | | trigger: 'axis', |
| | | }, |
| | | toolbox: { |
| | | show: true, |
| | | feature: { |
| | | dataZoom: { |
| | | yAxisIndex: 'none', |
| | | }, |
| | | myBar: { |
| | | title: '转化为柱状图', |
| | | show: true, |
| | | icon: PATH_ICON.bar, |
| | | onclick: () => { |
| | | chartInstance.setOption({ |
| | | series: { |
| | | data: props.data.values, |
| | | type: 'bar', |
| | | symbol: 'none', |
| | | }, |
| | | }); |
| | | }, |
| | | }, |
| | | |
| | | myScatter: { |
| | | title: '转化为散点图', |
| | | show: true, |
| | | icon: PATH_ICON.scatter, |
| | | onclick: () => { |
| | | chartInstance.setOption({ |
| | | data: props.data.values, |
| | | type: 'scatter', |
| | | symbol: 'circle', |
| | | symbolSize: SCATTER_SYMBOL_SIZE, |
| | | }); |
| | | }, |
| | | }, |
| | | myLine: { |
| | | title: '转化为曲线图', |
| | | show: true, |
| | | icon: PATH_ICON.line, |
| | | onclick: () => { |
| | | chartInstance.setOption({ |
| | | data: props.data.values, |
| | | type: 'line', |
| | | symbol: 'none', |
| | | smooth: true, |
| | | }); |
| | | }, |
| | | }, |
| | | dataView: { |
| | | readOnly: true, |
| | | optionToContent: timeDataOptionToContent, |
| | | }, |
| | | saveAsImage: {}, |
| | | }, |
| | | }, |
| | | |
| | | title: { |
| | | text: props.data.title, |
| | | left: 'center', |
| | | |
| | | }, |
| | | xAxis: { |
| | | name: props.data?.names[0], |
| | |
| | | series: [ |
| | | { |
| | | data: props.data.values, |
| | | symbol: 'none', |
| | | smooth: true, |
| | | type: chartTypeMapEchart[selectChartType.value], |
| | | }, |
| | | ], |
| | |
| | | |
| | | onMounted(() => { |
| | | setTimeout(() => { |
| | | |
| | | const parent = chartRef.value.parentElement; |
| | | if(!parent){ |
| | | if (!parent) { |
| | | } |
| | | const parentBound = parent.getBoundingClientRect(); |
| | | chartInstance = echarts.init(chartRef.value,undefined,{ |
| | | width:parentBound.width, |
| | | height:parentBound.height |
| | | chartInstance = echarts.init(chartRef.value, undefined, { |
| | | width: parentBound.width, |
| | | height: parentBound.height, |
| | | }); |
| | | |
| | | drawChart(); |