| | |
| | | type: String, |
| | | required: false, |
| | | }, |
| | | tableHeight: { |
| | | type: Number, |
| | | default: document.body.clientHeight * 0.7, |
| | | }, |
| | | showFilter: { |
| | | type: Boolean, |
| | | default: true, |
| | |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | }) as { |
| | | data: any; |
| | | summaryIndex: number; |
| | | showFilter: Boolean; |
| | | }; |
| | | reportIndex: { |
| | | type: Number, |
| | | default: 0, |
| | | }, |
| | | historyId: { |
| | | type: String, |
| | | }, |
| | | }); |
| | | |
| | | const tableLimitHeight = props.chartHeight == undefined ? undefined : document.body.clientHeight * 0.7; |
| | | const tableLimitHeight = props.chartHeight == undefined ? undefined : props.tableHeight; |
| | | |
| | | const chartLoading = ref(false); |
| | | |
| | |
| | | const getVisibleParams = (data) => { |
| | | // const visibleList = props.data?.params?.filter((item) => !item?.hide) ?? []; |
| | | // index 作为 id |
| | | const dataFilter = data?.filter ?? []; |
| | | const visibleList = (data?.filter ?? []).map((item, index) => { |
| | | // 不修改原始地址 |
| | | item.id = index + ''; |
| | |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const visibleParams = ref(getVisibleParams(props.data)); |
| | | |
| | | const checkIsDayTime = () => { |
| | |
| | | const values = groupedValues[item]; |
| | | return { |
| | | name: item === 'default' ? '' : item, |
| | | data: values.map((item) => [item[timeIndex], item[valueIndex]]), |
| | | data: values |
| | | .map((item) => [item[timeIndex], item[valueIndex]]) |
| | | .toSorted((b, a) => { |
| | | return b[timeIndex].localeCompare(a[timeIndex]); |
| | | }), |
| | | ...getChartTypeSeriesOption(activeChartType), |
| | | }; |
| | | }); |
| | |
| | | } |
| | | : axisLabelFormatter; |
| | | |
| | | const tooltipValueFormatter = |
| | | originChartType === ChartTypeEnum.Score |
| | | ? (value) => { |
| | | return scoreMap[value]; |
| | | } |
| | | : undefined; |
| | | const tooltipValueFormatter = (value) => { |
| | | const realValue = originChartType === ChartTypeEnum.Score ? scoreMap[value] : value; |
| | | return realValue + (props.data.unit ? ` ${props.data.unit}` : ''); |
| | | }; |
| | | |
| | | const scoreYAxisOption: echarts.YAXisComponentOption = { |
| | | min: 0, |
| | |
| | | name: timeCol?.title, |
| | | }, |
| | | yAxis: { |
| | | name: valueCol?.title, |
| | | name: props.data.unit ? `${props.data.unit}` : valueCol?.title, |
| | | |
| | | /** @description 不强制保留 */ |
| | | scale: true, |
| | | ...(originChartType === ChartTypeEnum.Score ? scoreYAxisOption : {}), |
| | |
| | | const values = groupedValues[item]; |
| | | return { |
| | | name: item === 'default' ? '' : item, |
| | | data: values.map((item) => [item[timeIndex], item[valueIndex]]), |
| | | data: values |
| | | .map((item) => [item[timeIndex], item[valueIndex]]) |
| | | .toSorted((b, a) => { |
| | | return b[timeIndex].localeCompare(a[timeIndex]); |
| | | }), |
| | | }; |
| | | })), |
| | | chartInstance.value?.setOption({ |
| | |
| | | }; |
| | | const handleQueryChange = async (val: any, item: RecordSetParamsItem) => { |
| | | if (!val) return; |
| | | const historyId = (props as any).originData.historyId; |
| | | const historyId = props.historyId; |
| | | let res = null; |
| | | |
| | | // 改变原始值 |
| | |
| | | // 查询前后 agent_key 不会变 |
| | | agent_key: props.data.agent_key, |
| | | filter_json: JSON.stringify(filterList), |
| | | result_group_index: props.reportIndex, |
| | | }; |
| | | res = await curveQuery(params); |
| | | chartLoading.value = true; |
| | |
| | | }, []); |
| | | const series = seriesData.map<echarts.SeriesOption>((item) => ({ |
| | | name: item[0]?.[nameIndex], |
| | | data: item.map((item) => [item[timeIndex], item[valueIndex]]), |
| | | data: item |
| | | .map((item) => [item[timeIndex], item[valueIndex]]) |
| | | .toSorted((b, a) => { |
| | | return b[timeIndex].localeCompare(a[timeIndex]); |
| | | }), |
| | | ...getChartTypeSeriesOption(activeChartType), |
| | | })); |
| | | setNewOption(series, getSingleDayOption()); |
| | |
| | | .toSorted((b, a) => { |
| | | return b[0].localeCompare(a[0]); |
| | | }); |
| | | const getColName = (name) => { |
| | | if (props.data.unit) { |
| | | return `${name}(${props.data.unit})`; |
| | | } |
| | | return name; |
| | | }; |
| | | const cols = currentSeries.value.map((item, index) => ({ |
| | | title: item.name ?? `值${index + 1}`, |
| | | title: getColName(item.name ?? `值${index + 1}`), |
| | | type: 'text', |
| | | })); |
| | | |
| | |
| | | updateCurrent(summary?.[props.summaryIndex], true); |
| | | }; |
| | | |
| | | const clearChart = () => { |
| | | chartInstance.value.setOption( |
| | | { |
| | | title: { |
| | | text: '', |
| | | }, |
| | | series: [], |
| | | }, |
| | | true |
| | | ); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | drawChart, |
| | | isMultiCompare, |
| | | handleMultiCompare, |
| | | handleData, |
| | | updateAll, |
| | | |
| | | clearChart, |
| | | updateIndexSummary, |
| | | }); |
| | | </script> |