mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
commit
a25f9bc5a1
@ -53,11 +53,10 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, watch, reactive, PropType } from 'vue'
|
import { onMounted, watch, reactive, PropType } from 'vue'
|
||||||
import merge from 'lodash/merge'
|
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
|
||||||
import { useChartDataFetch } from '@/hooks'
|
import { useChartDataFetch } from '@/hooks'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import config, { option } from './config'
|
import config, { option } from './config'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
type DataProps = {
|
type DataProps = {
|
||||||
name: string | number
|
name: string | number
|
||||||
@ -114,12 +113,11 @@ watch(
|
|||||||
|
|
||||||
const calcData = (data: any) => {
|
const calcData = (data: any) => {
|
||||||
mergeConfig(props.chartConfig.option)
|
mergeConfig(props.chartConfig.option)
|
||||||
|
|
||||||
calcCapsuleLengthAndLabelData()
|
calcCapsuleLengthAndLabelData()
|
||||||
}
|
}
|
||||||
|
|
||||||
const mergeConfig = (data: any) => {
|
const mergeConfig = (data: any) => {
|
||||||
state.mergedConfig = merge(cloneDeep(state.defaultConfig), data || {})
|
state.mergedConfig = cloneDeep(data || {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据解析
|
// 数据解析
|
||||||
|
@ -62,7 +62,7 @@ const status = reactive({
|
|||||||
const calcRowsData = () => {
|
const calcRowsData = () => {
|
||||||
let { dataset, rowNum, sort } = status.mergedConfig
|
let { dataset, rowNum, sort } = status.mergedConfig
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sort && dataset.sort(({ value: a }, { value: b }) => {
|
sort &&dataset.sort(({ value: a }, { value: b } ) => {
|
||||||
if (a > b) return -1
|
if (a > b) return -1
|
||||||
if (a < b) return 1
|
if (a < b) return 1
|
||||||
if (a === b) return 0
|
if (a === b) return 0
|
||||||
@ -94,6 +94,7 @@ const calcHeights = (onresize = false) => {
|
|||||||
const { rowNum, dataset } = status.mergedConfig
|
const { rowNum, dataset } = status.mergedConfig
|
||||||
const avgHeight = h.value / rowNum
|
const avgHeight = h.value / rowNum
|
||||||
status.avgHeight = avgHeight
|
status.avgHeight = avgHeight
|
||||||
|
|
||||||
if (!onresize) status.heights = new Array(dataset.length).fill(avgHeight)
|
if (!onresize) status.heights = new Array(dataset.length).fill(avgHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +132,17 @@ const stopAnimation = () => {
|
|||||||
const onRestart = async () => {
|
const onRestart = async () => {
|
||||||
try {
|
try {
|
||||||
if (!status.mergedConfig) return
|
if (!status.mergedConfig) return
|
||||||
|
let { dataset, rowNum, sort } = status.mergedConfig
|
||||||
stopAnimation()
|
stopAnimation()
|
||||||
calcRowsData()
|
calcRowsData()
|
||||||
calcHeights(true)
|
let flag = true
|
||||||
animation(true)
|
if (dataset.length <= rowNum) {
|
||||||
|
flag=false
|
||||||
|
}
|
||||||
|
calcHeights(flag)
|
||||||
|
animation(flag)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user