Browse Source

回退版本

master
liuchen864 5 months ago
parent
commit
d284ed410d
  1. 9
      src/hooks/useChartDataFetch.hook.ts
  2. 25
      src/packages/components/Charts/Bars/BarCommon/index.vue
  3. 3
      src/utils/utils.ts

9
src/hooks/useChartDataFetch.hook.ts

@ -39,7 +39,7 @@ export const useChartDataFetch = (
}
}
const requestIntervalFn =async () => {
const requestIntervalFn = () => {
const chartEditStore = useChartEditStore()
// 全局数据
@ -75,11 +75,10 @@ export const useChartDataFetch = (
if (res) {
try {
const filter = targetComponent.filter
res.data = res.source
echartsUpdateHandle(newFunctionHandle(res?.data, res, filter))
// 更新回调函数
if (updateCallback) {
updateCallback(newFunctionHandle(res?.data, res, filter),res)
updateCallback(newFunctionHandle(res?.data, res, filter))
}
} catch (error) {
console.error(error)
@ -88,9 +87,7 @@ export const useChartDataFetch = (
}
// 立即调用
await fetchFn()
// fetchFn()
fetchFn()
// 定时时间
const time = targetInterval && targetInterval.value ? targetInterval.value : globalRequestInterval.value
// 单位

25
src/packages/components/Charts/Bars/BarCommon/index.vue

@ -7,7 +7,6 @@
:update-options="{
replaceMerge: replaceMergeArr
}"
:key="key"
autoresize
></v-chart>
</template>
@ -46,17 +45,9 @@ use([DatasetComponent, CanvasRenderer, BarChart, GridComponent, TooltipComponent
const replaceMergeArr = ref<string[]>()
const dataset1 = ref()
const dataset2 = ref(props.chartConfig.option)
const key = ref(0)
const option = ref()
// const option = computed(() => {
// if(dataset1.value){
// dataset2.value.dataset = dataset1.value
// }
// key.value++
// return mergeTheme(dataset2.value, props.themeSetting, includes)
// })
const option = computed(() => {
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
})
// dataset
watch(
@ -83,14 +74,6 @@ watch(
deep: false
}
)
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore,(dataset,res)=>{
dataset1.value = {
source : res.source,
dimensions : res.dimensions,
}
dataset2.value.dataset = dataset1.value
option.value = mergeTheme(dataset2.value, props.themeSetting, includes)
key.value++
})
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
</script>

3
src/utils/utils.ts

@ -193,8 +193,7 @@ export const newFunctionHandle = (
try {
if (!funcStr) return data
const fn = new Function('data', 'res', funcStr)
const fnRes = fn(res,data)
// const fnRes = fn(cloneDeep(data), cloneDeep(res))
const fnRes = fn(cloneDeep(data), cloneDeep(res))
const resHandle = isToString ? toString(fnRes) : fnRes
// 成功回调
successCallBack && successCallBack(resHandle)

Loading…
Cancel
Save