| | |
| | | <div class="w-full flex-column"> |
| | | <div class="flex mb-4 flex-wrap flex-0"> |
| | | <!-- TimeRange v-model 跟 @change 中的值会不一样,以@change 中为准 --> |
| | | <template v-if="visibleParams && visibleParams.length > 0"> |
| | | <template v-if="visibleParams && visibleParams.length > 0 && showFilter"> |
| | | <component |
| | | class="flex-0 m-2" |
| | | v-model="visibleParams[index].value" |
| | |
| | | chartHeight: { |
| | | type: String, |
| | | required: false, |
| | | }, |
| | | showFilter: { |
| | | type: Boolean, |
| | | default: true, |
| | | }, |
| | | }) as { |
| | | data: any; |
| | |
| | | }; |
| | | const { chartContainerResize, chartInstance } = useDrawChatChart({ chartRef, drawChart }); |
| | | |
| | | const updateCurrent = (res) => { |
| | | const updateCurrent = (res, isNew = false) => { |
| | | const title = res?.title; |
| | | const values = res?.values ?? []; |
| | | //#region ====================== 刷新当前 filter ====================== |
| | | // 只更新 value,不直接覆盖,防止丢失响应性 |
| | | updateVisibleParams(res); |
| | | // updateVisibleParams(res); |
| | | //#endregion |
| | | groupedValues = _.groupBy(values, (item) => item[nameIndex]); |
| | | if (isMultiCompare.value) { |
| | | handleMultiCompare(); |
| | | } else { |
| | | (currentSeries.value = |
| | | groupedValues && |
| | | Object.keys(groupedValues).map((item, index) => { |
| | | const values = groupedValues[item]; |
| | | return { |
| | | name: currentSeries.value[index].name, |
| | | data: values.map((item) => [item[timeIndex], item[valueIndex]]), |
| | | }; |
| | | })), |
| | | chartInstance.value.setOption({ |
| | | title: { |
| | | text: title, |
| | | }, |
| | | series: currentSeries.value, |
| | | }); |
| | | if (isNew) { |
| | | setNewOption(); |
| | | } else { |
| | | (currentSeries.value = |
| | | groupedValues && |
| | | Object.keys(groupedValues).map((item, index) => { |
| | | const values = groupedValues[item]; |
| | | return { |
| | | name: item === 'default' ? '' : item, |
| | | data: values.map((item) => [item[timeIndex], item[valueIndex]]), |
| | | }; |
| | | })), |
| | | chartInstance.value?.setOption({ |
| | | title: { |
| | | text: title, |
| | | }, |
| | | series: currentSeries.value, |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | |
| | | updateCurrent(newSummary); |
| | | }; |
| | | |
| | | const updateIndexSummary = (summary) => { |
| | | updateCurrent(summary?.[props.summaryIndex],true); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | drawChart, |
| | | isMultiCompare, |
| | | handleMultiCompare, |
| | | handleData, |
| | | updateAll, |
| | | |
| | | updateIndexSummary, |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"></style> |