perf: 优化异常处理
This commit is contained in:
parent
b2eb54ca4b
commit
37593bc257
@ -53,17 +53,21 @@ const option = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: { dimensions: any }, oldData) => {
|
(newData: { dimensions: any }, oldData) => {
|
||||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
try {
|
||||||
if (Array.isArray(newData?.dimensions)) {
|
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||||
const seriesArr = []
|
if (Array.isArray(newData?.dimensions)) {
|
||||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
const seriesArr = []
|
||||||
seriesArr.push(seriesItem)
|
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||||
|
seriesArr.push(seriesItem)
|
||||||
|
}
|
||||||
|
replaceMergeArr.value = ['series']
|
||||||
|
props.chartConfig.option.series = seriesArr
|
||||||
|
nextTick(() => {
|
||||||
|
replaceMergeArr.value = []
|
||||||
|
})
|
||||||
}
|
}
|
||||||
replaceMergeArr.value = ['series']
|
} catch (error) {
|
||||||
props.chartConfig.option.series = seriesArr
|
console.log(error)
|
||||||
nextTick(() => {
|
|
||||||
replaceMergeArr.value = []
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -52,17 +52,21 @@ const option = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: { dimensions: any }, oldData) => {
|
(newData: { dimensions: any }, oldData) => {
|
||||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
try {
|
||||||
if (Array.isArray(newData?.dimensions)) {
|
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||||
const seriesArr = []
|
if (Array.isArray(newData?.dimensions)) {
|
||||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
const seriesArr = []
|
||||||
seriesArr.push(seriesItem)
|
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||||
|
seriesArr.push(seriesItem)
|
||||||
|
}
|
||||||
|
replaceMergeArr.value = ['series']
|
||||||
|
props.chartConfig.option.series = seriesArr
|
||||||
|
nextTick(() => {
|
||||||
|
replaceMergeArr.value = []
|
||||||
|
})
|
||||||
}
|
}
|
||||||
replaceMergeArr.value = ['series']
|
} catch (error) {
|
||||||
props.chartConfig.option.series = seriesArr
|
console.log(error)
|
||||||
nextTick(() => {
|
|
||||||
replaceMergeArr.value = []
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -53,17 +53,21 @@ const option = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: { dimensions: any }, oldData) => {
|
(newData: { dimensions: any }, oldData) => {
|
||||||
if (!isObject(newData) || !('dimensions' in newData)) return
|
try {
|
||||||
if (Array.isArray(newData?.dimensions)) {
|
if (!isObject(newData) || !('dimensions' in newData)) return
|
||||||
const seriesArr = []
|
if (Array.isArray(newData?.dimensions)) {
|
||||||
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
const seriesArr = []
|
||||||
seriesArr.push(seriesItem)
|
for (let i = 0; i < newData.dimensions.length - 1; i++) {
|
||||||
|
seriesArr.push(seriesItem)
|
||||||
|
}
|
||||||
|
replaceMergeArr.value = ['series']
|
||||||
|
props.chartConfig.option.series = seriesArr
|
||||||
|
nextTick(() => {
|
||||||
|
replaceMergeArr.value = []
|
||||||
|
})
|
||||||
}
|
}
|
||||||
replaceMergeArr.value = ['series']
|
} catch (error) {
|
||||||
props.chartConfig.option.series = seriesArr
|
console.log(error)
|
||||||
nextTick(() => {
|
|
||||||
replaceMergeArr.value = []
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-chart
|
<v-chart ref="vChartRef" :theme="themeColor" :option="option.value" :manual-update="isPreview()" autoresize>
|
||||||
ref="vChartRef"
|
|
||||||
:theme="themeColor"
|
|
||||||
:option="option.value"
|
|
||||||
:manual-update="isPreview()"
|
|
||||||
autoresize>
|
|
||||||
</v-chart>
|
</v-chart>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -37,14 +32,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
use([
|
use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent])
|
||||||
DatasetComponent,
|
|
||||||
CanvasRenderer,
|
|
||||||
LineChart,
|
|
||||||
GridComponent,
|
|
||||||
TooltipComponent,
|
|
||||||
LegendComponent,
|
|
||||||
])
|
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
@ -52,32 +40,42 @@ const option = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 渐变色处理
|
// 渐变色处理
|
||||||
watch(() => chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
watch(
|
||||||
if (!isPreview()) {
|
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
(newColor: keyof typeof chartColorsSearch) => {
|
||||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
try {
|
||||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
if (!isPreview()) {
|
||||||
{
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
offset: 0,
|
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||||
color: themeColor[3]
|
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
},
|
{
|
||||||
{
|
offset: 0,
|
||||||
offset: 1,
|
color: themeColor[3]
|
||||||
color: 'rgba(0,0,0, 0)'
|
},
|
||||||
}
|
{
|
||||||
])
|
offset: 1,
|
||||||
})
|
color: 'rgba(0,0,0, 0)'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
props.chartConfig.option = option.value
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
)
|
||||||
props.chartConfig.option = option.value
|
|
||||||
}, {
|
|
||||||
immediate: true
|
|
||||||
})
|
|
||||||
|
|
||||||
|
watch(
|
||||||
watch(() => props.chartConfig.option.dataset, () => {
|
() => props.chartConfig.option.dataset,
|
||||||
option.value = props.chartConfig.option
|
() => {
|
||||||
})
|
option.value = props.chartConfig.option
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,93 +1,79 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-chart
|
<v-chart ref="vChartRef" :theme="themeColor" :option="option.value" :manual-update="isPreview()" autoresize></v-chart>
|
||||||
ref="vChartRef"
|
|
||||||
:theme="themeColor"
|
|
||||||
:option="option.value"
|
|
||||||
:manual-update="isPreview()"
|
|
||||||
autoresize
|
|
||||||
></v-chart>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watch, PropType } from "vue";
|
import { reactive, watch, PropType } from 'vue'
|
||||||
import VChart from "vue-echarts";
|
import VChart from 'vue-echarts'
|
||||||
import { use, graphic } from "echarts/core";
|
import { use, graphic } from 'echarts/core'
|
||||||
import { CanvasRenderer } from "echarts/renderers";
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
import { LineChart } from "echarts/charts";
|
import { LineChart } from 'echarts/charts'
|
||||||
import config, { includes } from "./config";
|
import config, { includes } from './config'
|
||||||
import { mergeTheme } from "@/packages/public/chart";
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { chartColorsSearch, defaultTheme } from "@/settings/chartThemes/index";
|
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
|
||||||
import {
|
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
|
||||||
DatasetComponent,
|
import { useChartDataFetch } from '@/hooks'
|
||||||
GridComponent,
|
import { isPreview } from '@/utils'
|
||||||
TooltipComponent,
|
|
||||||
LegendComponent,
|
|
||||||
} from "echarts/components";
|
|
||||||
import { useChartDataFetch } from "@/hooks";
|
|
||||||
import { isPreview } from "@/utils";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
themeSetting: {
|
themeSetting: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true
|
||||||
},
|
},
|
||||||
themeColor: {
|
themeColor: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true
|
||||||
},
|
},
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<config>,
|
type: Object as PropType<config>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
use([
|
use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent])
|
||||||
DatasetComponent,
|
const chartEditStore = useChartEditStore()
|
||||||
CanvasRenderer,
|
|
||||||
LineChart,
|
|
||||||
GridComponent,
|
|
||||||
TooltipComponent,
|
|
||||||
LegendComponent,
|
|
||||||
]);
|
|
||||||
const chartEditStore = useChartEditStore();
|
|
||||||
|
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
value: {},
|
value: {}
|
||||||
});
|
})
|
||||||
|
|
||||||
// 渐变色处理
|
// 渐变色处理
|
||||||
watch(
|
watch(
|
||||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||||
(newColor: keyof typeof chartColorsSearch) => {
|
(newColor: keyof typeof chartColorsSearch) => {
|
||||||
if (!isPreview()) {
|
try {
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme];
|
if (!isPreview()) {
|
||||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||||
{
|
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
offset: 0,
|
{
|
||||||
color: themeColor[3 + index],
|
offset: 0,
|
||||||
},
|
color: themeColor[3 + index]
|
||||||
{
|
},
|
||||||
offset: 1,
|
{
|
||||||
color: "rgba(0,0,0, 0)",
|
offset: 1,
|
||||||
},
|
color: 'rgba(0,0,0, 0)'
|
||||||
]);
|
}
|
||||||
});
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
props.chartConfig.option = option.value
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes);
|
|
||||||
props.chartConfig.option = option.value;
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
() => {
|
() => {
|
||||||
option.value = props.chartConfig.option;
|
option.value = props.chartConfig.option
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore);
|
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||||
</script>
|
</script>
|
||||||
|
@ -43,17 +43,21 @@ const option = reactive({
|
|||||||
watch(
|
watch(
|
||||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||||
(newColor: keyof typeof chartColorsSearch) => {
|
(newColor: keyof typeof chartColorsSearch) => {
|
||||||
if (!isPreview()) {
|
try {
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
if (!isPreview()) {
|
||||||
props.chartConfig.option.series.forEach((value: any) => {
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
value.lineStyle.shadowColor = themeColor[2]
|
props.chartConfig.option.series.forEach((value: any) => {
|
||||||
value.lineStyle.color.colorStops.forEach((v: { color: string }, i: number) => {
|
value.lineStyle.shadowColor = themeColor[2]
|
||||||
v.color = themeColor[i]
|
value.lineStyle.color.colorStops.forEach((v: { color: string }, i: number) => {
|
||||||
|
v.color = themeColor[i]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
props.chartConfig.option = option.value
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
|
||||||
props.chartConfig.option = option.value
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
|
@ -64,9 +64,9 @@ registerMap(props.chartConfig.option.mapRegion.adcode, { geoJSON: {} as any, spe
|
|||||||
// 进行更换初始化地图 如果为china 单独处理
|
// 进行更换初始化地图 如果为china 单独处理
|
||||||
const registerMapInitAsync = async () => {
|
const registerMapInitAsync = async () => {
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (props.chartConfig.option.mapRegion.adcode!="china") {
|
if (props.chartConfig.option.mapRegion.adcode != 'china') {
|
||||||
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
||||||
}else{
|
} else {
|
||||||
await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands)
|
await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands)
|
||||||
}
|
}
|
||||||
vEchartsSetOption()
|
vEchartsSetOption()
|
||||||
@ -90,12 +90,12 @@ const dataSetHandle = async (dataset: any) => {
|
|||||||
isPreview() && vEchartsSetOption()
|
isPreview() && vEchartsSetOption()
|
||||||
}
|
}
|
||||||
// 处理海南群岛
|
// 处理海南群岛
|
||||||
const hainanLandsHandle=async(newData:boolean)=>{
|
const hainanLandsHandle = async (newData: boolean) => {
|
||||||
if (newData) {
|
if (newData) {
|
||||||
await getGeojson('china')
|
await getGeojson('china')
|
||||||
} else {
|
} else {
|
||||||
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//监听 dataset 数据发生变化
|
//监听 dataset 数据发生变化
|
||||||
watch(
|
watch(
|
||||||
@ -113,8 +113,12 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.mapRegion.showHainanIsLands,
|
() => props.chartConfig.option.mapRegion.showHainanIsLands,
|
||||||
async newData => {
|
async newData => {
|
||||||
await hainanLandsHandle(newData)
|
try {
|
||||||
vEchartsSetOption()
|
await hainanLandsHandle(newData)
|
||||||
|
vEchartsSetOption()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
@ -125,12 +129,16 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.mapRegion.adcode,
|
() => props.chartConfig.option.mapRegion.adcode,
|
||||||
async newData => {
|
async newData => {
|
||||||
await getGeojson(newData)
|
try {
|
||||||
props.chartConfig.option.geo.map = newData
|
await getGeojson(newData)
|
||||||
props.chartConfig.option.series.forEach((item: any) => {
|
props.chartConfig.option.geo.map = newData
|
||||||
if (item.type === 'map') item.map = newData
|
props.chartConfig.option.series.forEach((item: any) => {
|
||||||
})
|
if (item.type === 'map') item.map = newData
|
||||||
vEchartsSetOption()
|
})
|
||||||
|
vEchartsSetOption()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -75,7 +75,11 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
newData => {
|
newData => {
|
||||||
dataSetHandle(newData)
|
try {
|
||||||
|
dataSetHandle(newData)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -57,7 +57,11 @@ const option = shallowReactive({
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: any) => {
|
(newData: any) => {
|
||||||
option.dataset = toNumber(newData, 2)
|
try {
|
||||||
|
option.dataset = toNumber(newData, 2)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -57,7 +57,11 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
newData => {
|
newData => {
|
||||||
dataSetHandle(newData)
|
try {
|
||||||
|
dataSetHandle(newData)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -49,8 +49,12 @@ const dataSetHandle = (dataset: typeof dataJson) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
newData => {
|
newData => {
|
||||||
if(!isArray(newData)) return
|
try {
|
||||||
dataSetHandle(newData)
|
if (!isArray(newData)) return
|
||||||
|
dataSetHandle(newData)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -42,23 +42,27 @@ const option = reactive({
|
|||||||
watch(
|
watch(
|
||||||
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
|
||||||
(newColor: keyof typeof chartColorsSearch) => {
|
(newColor: keyof typeof chartColorsSearch) => {
|
||||||
if (!isPreview()) {
|
try {
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
if (!isPreview()) {
|
||||||
// 背景颜色
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2]
|
// 背景颜色
|
||||||
// 水球颜色
|
props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2]
|
||||||
props.chartConfig.option.series[0].color[0].colorStops = [
|
// 水球颜色
|
||||||
{
|
props.chartConfig.option.series[0].color[0].colorStops = [
|
||||||
offset: 0,
|
{
|
||||||
color: themeColor[0]
|
offset: 0,
|
||||||
},
|
color: themeColor[0]
|
||||||
{
|
},
|
||||||
offset: 1,
|
{
|
||||||
color: themeColor[1]
|
offset: 1,
|
||||||
}
|
color: themeColor[1]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
option.value = props.chartConfig.option
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
option.value = props.chartConfig.option
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
@ -75,7 +79,7 @@ const dataHandle = (newData: number | string) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
newData => {
|
newData => {
|
||||||
if(!isString(newData) && !isNumber(newData)) return
|
if (!isString(newData) && !isNumber(newData)) return
|
||||||
props.chartConfig.option.series[0].data = [dataHandle(newData)]
|
props.chartConfig.option.series[0].data = [dataHandle(newData)]
|
||||||
option.value = props.chartConfig.option
|
option.value = props.chartConfig.option
|
||||||
},
|
},
|
||||||
|
@ -48,7 +48,13 @@ const dataHandle = (newData: any) => {
|
|||||||
// 配置时
|
// 配置时
|
||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
newData => dataHandle(newData),
|
newData => {
|
||||||
|
try {
|
||||||
|
dataHandle(newData)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
deep: false
|
deep: false
|
||||||
|
@ -39,15 +39,19 @@ const option = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.type,
|
() => props.chartConfig.option.type,
|
||||||
newData => {
|
newData => {
|
||||||
if (newData === 'nomal') {
|
try {
|
||||||
props.chartConfig.option.series[0].radius = '70%'
|
if (newData === 'nomal') {
|
||||||
props.chartConfig.option.series[0].roseType = false
|
props.chartConfig.option.series[0].radius = '70%'
|
||||||
} else if (newData === 'ring') {
|
props.chartConfig.option.series[0].roseType = false
|
||||||
props.chartConfig.option.series[0].radius = ['40%', '65%']
|
} else if (newData === 'ring') {
|
||||||
props.chartConfig.option.series[0].roseType = false
|
props.chartConfig.option.series[0].radius = ['40%', '65%']
|
||||||
} else {
|
props.chartConfig.option.series[0].roseType = false
|
||||||
props.chartConfig.option.series[0].radius = '70%'
|
} else {
|
||||||
props.chartConfig.option.series[0].roseType = true
|
props.chartConfig.option.series[0].radius = '70%'
|
||||||
|
props.chartConfig.option.series[0].roseType = true
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: false, immediate: true }
|
{ deep: false, immediate: true }
|
||||||
|
@ -69,17 +69,21 @@ const option = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData, oldData) => {
|
(newData, oldData) => {
|
||||||
if (!isArray(newData)) return
|
try {
|
||||||
if (Array.isArray(newData)) {
|
if (!isArray(newData)) return
|
||||||
replaceMergeArr.value = ['series']
|
if (Array.isArray(newData)) {
|
||||||
// eslint-disable-next-line vue/no-mutating-props
|
replaceMergeArr.value = ['series']
|
||||||
props.chartConfig.option.series = newData.map((item: { dimensions: any[] }, index: number) => ({
|
// eslint-disable-next-line vue/no-mutating-props
|
||||||
...seriesItem,
|
props.chartConfig.option.series = newData.map((item: { dimensions: any[] }, index: number) => ({
|
||||||
datasetIndex: index
|
...seriesItem,
|
||||||
}))
|
datasetIndex: index
|
||||||
nextTick(() => {
|
}))
|
||||||
replaceMergeArr.value = []
|
nextTick(() => {
|
||||||
})
|
replaceMergeArr.value = []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -133,10 +133,14 @@ const renderCountdown: CountdownProps['render'] = ({ hours, minutes, seconds })
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updateTotalDuration = () => {
|
const updateTotalDuration = () => {
|
||||||
countdownActive.value = false
|
try {
|
||||||
totalDuration.value = useEndDate.value ? endDate.value - new Date().getTime() : dataset.value * 1000
|
countdownActive.value = false
|
||||||
countdownRef.value?.reset && countdownRef.value?.reset()
|
totalDuration.value = useEndDate.value ? endDate.value - new Date().getTime() : dataset.value * 1000
|
||||||
countdownActive.value = true
|
countdownRef.value?.reset && countdownRef.value?.reset()
|
||||||
|
countdownActive.value = true
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -60,7 +60,11 @@ const updateDatasetHandler = (newVal: string | number) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option,
|
() => props.chartConfig.option,
|
||||||
newVal => {
|
newVal => {
|
||||||
updateDatasetHandler((newVal as OptionType).dataset)
|
try {
|
||||||
|
updateDatasetHandler((newVal as OptionType).dataset)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
@ -11,23 +11,23 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType, toRefs, ref, reactive, watch, onMounted, onUnmounted } from "vue";
|
import { PropType, toRefs, ref, reactive, watch, onMounted, onUnmounted } from 'vue'
|
||||||
import { CreateComponentType } from "@/packages/index.d";
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { useChartDataFetch } from "@/hooks";
|
import { useChartDataFetch } from '@/hooks'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<CreateComponentType>,
|
type: Object as PropType<CreateComponentType>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
let yearMonthDay = ref("2021-2-3");
|
let yearMonthDay = ref('2021-2-3')
|
||||||
let nowData = ref("08:00:00");
|
let nowData = ref('08:00:00')
|
||||||
let newData = ref("2021-2-3 08:00:00");
|
let newData = ref('2021-2-3 08:00:00')
|
||||||
let boxShadow = ref("none");
|
let boxShadow = ref('none')
|
||||||
|
|
||||||
const { w, h } = toRefs(props.chartConfig.attr);
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
|
|
||||||
let {
|
let {
|
||||||
timeColor,
|
timeColor,
|
||||||
@ -39,54 +39,55 @@ let {
|
|||||||
hShadow,
|
hShadow,
|
||||||
vShadow,
|
vShadow,
|
||||||
blurShadow,
|
blurShadow,
|
||||||
colorShadow,
|
colorShadow
|
||||||
} = toRefs(props.chartConfig.option);
|
} = toRefs(props.chartConfig.option)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
props.chartConfig.option,
|
props.chartConfig.option,
|
||||||
() => {
|
() => {
|
||||||
if (props.chartConfig.option.showShadow) {
|
try {
|
||||||
boxShadow.value = `${props.chartConfig.option.hShadow}px ${props.chartConfig.option.vShadow}px ${props.chartConfig.option.blurShadow}px ${props.chartConfig.option.colorShadow}`;
|
if (props.chartConfig.option.showShadow) {
|
||||||
} else {
|
boxShadow.value = `${props.chartConfig.option.hShadow}px ${props.chartConfig.option.vShadow}px ${props.chartConfig.option.blurShadow}px ${props.chartConfig.option.colorShadow}`
|
||||||
boxShadow.value = "none";
|
} else {
|
||||||
|
boxShadow.value = 'none'
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
var datetime = new Date();
|
var datetime = new Date()
|
||||||
var year = datetime.getFullYear();
|
var year = datetime.getFullYear()
|
||||||
var month =
|
var month = datetime.getMonth() + 1 < 10 ? '0' + (datetime.getMonth() + 1) : datetime.getMonth() + 1
|
||||||
datetime.getMonth() + 1 < 10
|
var date = datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate()
|
||||||
? "0" + (datetime.getMonth() + 1)
|
var hh = datetime.getHours() // 时
|
||||||
: datetime.getMonth() + 1;
|
var mm = datetime.getMinutes() // 分
|
||||||
var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
|
var ss = datetime.getSeconds() // 分
|
||||||
var hh = datetime.getHours(); // 时
|
let time = ''
|
||||||
var mm = datetime.getMinutes(); // 分
|
if (hh < 10) time += '0'
|
||||||
var ss = datetime.getSeconds(); // 分
|
time += hh + ':'
|
||||||
let time = "";
|
if (mm < 10) time += '0'
|
||||||
if (hh < 10) time += "0";
|
time += mm + ':'
|
||||||
time += hh + ":";
|
if (ss < 10) time += '0'
|
||||||
if (mm < 10) time += "0";
|
time += ss
|
||||||
time += mm + ":";
|
yearMonthDay.value = `${year}-${month}-${date}`
|
||||||
if (ss < 10) time += "0";
|
nowData.value = time
|
||||||
time += ss;
|
newData.value = yearMonthDay.value + ' ' + nowData.value
|
||||||
yearMonthDay.value = `${year}-${month}-${date}`;
|
}, 500)
|
||||||
nowData.value = time;
|
})
|
||||||
newData.value = yearMonthDay.value + " " + nowData.value;
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clearInterval();
|
clearInterval()
|
||||||
});
|
})
|
||||||
useChartDataFetch(props.chartConfig, useChartEditStore);
|
useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go("decorates-number") {
|
@include go('decorates-number') {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -47,9 +47,12 @@ const option = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataSetHandle = (dataset: typeof dataJson) => {
|
const dataSetHandle = (dataset: typeof dataJson) => {
|
||||||
dataset && (props.chartConfig.option.series[0].data = dataset)
|
try {
|
||||||
|
dataset && (props.chartConfig.option.series[0].data = dataset)
|
||||||
vChartRef.value && isPreview() && vChartRef.value.setOption(props.chartConfig.option)
|
vChartRef.value && isPreview() && vChartRef.value.setOption(props.chartConfig.option)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dataset 无法变更条数的补丁
|
// dataset 无法变更条数的补丁
|
||||||
|
@ -10,19 +10,12 @@
|
|||||||
<div class="rank" :style="`color: ${color};font-size: ${indexFontSize}px`">No.{{ item.ranking }}</div>
|
<div class="rank" :style="`color: ${color};font-size: ${indexFontSize}px`">No.{{ item.ranking }}</div>
|
||||||
<div class="info-name" :style="`font-size: ${leftFontSize}px`" v-html="item.name" />
|
<div class="info-name" :style="`font-size: ${leftFontSize}px`" v-html="item.name" />
|
||||||
<div class="ranking-value" :style="`color: ${textColor};font-size: ${rightFontSize}px`">
|
<div class="ranking-value" :style="`color: ${textColor};font-size: ${rightFontSize}px`">
|
||||||
{{
|
{{ status.mergedConfig.valueFormatter ? status.mergedConfig.valueFormatter(item) : item.value }}
|
||||||
status.mergedConfig.valueFormatter
|
|
||||||
? status.mergedConfig.valueFormatter(item)
|
|
||||||
: item.value
|
|
||||||
}}
|
|
||||||
{{ unit }}
|
{{ unit }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ranking-column" :style="`border-color: ${borderColor}`">
|
<div class="ranking-column" :style="`border-color: ${borderColor}`">
|
||||||
<div
|
<div class="inside-column" :style="`width: ${item.percent}%;background-color: ${color}`">
|
||||||
class="inside-column"
|
|
||||||
:style="`width: ${item.percent}%;background-color: ${color}`"
|
|
||||||
>
|
|
||||||
<div class="shine" />
|
<div class="shine" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,8 +32,8 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<CreateComponentType>,
|
type: Object as PropType<CreateComponentType>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
const { w, h } = toRefs(props.chartConfig.attr)
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
const { rowNum, unit, color, textColor, borderColor, indexFontSize, leftFontSize, rightFontSize } = toRefs(
|
const { rowNum, unit, color, textColor, borderColor, indexFontSize, leftFontSize, rightFontSize } = toRefs(
|
||||||
@ -50,13 +43,15 @@ const { rowNum, unit, color, textColor, borderColor, indexFontSize, leftFontSize
|
|||||||
const status = reactive({
|
const status = reactive({
|
||||||
mergedConfig: props.chartConfig.option,
|
mergedConfig: props.chartConfig.option,
|
||||||
rowsData: [],
|
rowsData: [],
|
||||||
rows: [{
|
rows: [
|
||||||
scroll: 0,
|
{
|
||||||
ranking: 1,
|
scroll: 0,
|
||||||
name: '',
|
ranking: 1,
|
||||||
value: '',
|
name: '',
|
||||||
percent: 0
|
value: '',
|
||||||
}],
|
percent: 0
|
||||||
|
}
|
||||||
|
],
|
||||||
heights: [0],
|
heights: [0],
|
||||||
animationIndex: 0,
|
animationIndex: 0,
|
||||||
animationHandler: 0,
|
animationHandler: 0,
|
||||||
@ -81,16 +76,16 @@ const calcRowsData = () => {
|
|||||||
// abs of max
|
// abs of max
|
||||||
const maxAbs = Math.abs(max)
|
const maxAbs = Math.abs(max)
|
||||||
const total = max + minAbs
|
const total = max + minAbs
|
||||||
dataset = dataset.map((row: any, i:number) => ({
|
dataset = dataset.map((row: any, i: number) => ({
|
||||||
...row,
|
...row,
|
||||||
ranking: i + 1,
|
ranking: i + 1,
|
||||||
percent: ((row.value + minAbs) / total) * 100,
|
percent: ((row.value + minAbs) / total) * 100
|
||||||
}))
|
}))
|
||||||
const rowLength = dataset.length
|
const rowLength = dataset.length
|
||||||
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
||||||
dataset = [...dataset, ...dataset]
|
dataset = [...dataset, ...dataset]
|
||||||
}
|
}
|
||||||
dataset = dataset.map((d:any, i:number) => ({ ...d, scroll: i }))
|
dataset = dataset.map((d: any, i: number) => ({ ...d, scroll: i }))
|
||||||
status.rowsData = dataset
|
status.rowsData = dataset
|
||||||
status.rows = dataset
|
status.rows = dataset
|
||||||
}
|
}
|
||||||
@ -134,11 +129,15 @@ const stopAnimation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onRestart = async () => {
|
const onRestart = async () => {
|
||||||
if (!status.mergedConfig) return
|
try {
|
||||||
stopAnimation()
|
if (!status.mergedConfig) return
|
||||||
calcRowsData()
|
stopAnimation()
|
||||||
calcHeights(true)
|
calcRowsData()
|
||||||
animation(true)
|
calcHeights(true)
|
||||||
|
animation(true)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRestart()
|
onRestart()
|
||||||
|
@ -1,24 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dv-scroll-board">
|
<div class="dv-scroll-board">
|
||||||
<div class="header" v-if="status.header.length && status.mergedConfig"
|
<div
|
||||||
:style="`background-color: ${status.mergedConfig.headerBGC};`">
|
class="header"
|
||||||
<div class="header-item" v-for="(headerItem, i) in status.header" :key="`${headerItem}${i}`" :style="`
|
v-if="status.header.length && status.mergedConfig"
|
||||||
|
:style="`background-color: ${status.mergedConfig.headerBGC};`"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="header-item"
|
||||||
|
v-for="(headerItem, i) in status.header"
|
||||||
|
:key="`${headerItem}${i}`"
|
||||||
|
:style="`
|
||||||
height: ${status.mergedConfig.headerHeight}px;
|
height: ${status.mergedConfig.headerHeight}px;
|
||||||
line-height: ${status.mergedConfig.headerHeight}px;
|
line-height: ${status.mergedConfig.headerHeight}px;
|
||||||
width: ${status.widths[i]}px;
|
width: ${status.widths[i]}px;
|
||||||
`" :align="status.aligns[i]" v-html="headerItem" />
|
`"
|
||||||
|
:align="status.aligns[i]"
|
||||||
|
v-html="headerItem"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="status.mergedConfig" class="rows"
|
<div
|
||||||
:style="`height: ${h - (status.header.length ? status.mergedConfig.headerHeight : 0)}px;`">
|
v-if="status.mergedConfig"
|
||||||
<div class="row-item" v-for="(row, ri) in status.rows" :key="`${row.toString()}${row.scroll}`" :style="`
|
class="rows"
|
||||||
|
:style="`height: ${h - (status.header.length ? status.mergedConfig.headerHeight : 0)}px;`"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="row-item"
|
||||||
|
v-for="(row, ri) in status.rows"
|
||||||
|
:key="`${row.toString()}${row.scroll}`"
|
||||||
|
:style="`
|
||||||
height: ${status.heights[ri]}px;
|
height: ${status.heights[ri]}px;
|
||||||
line-height: ${status.heights[ri]}px;
|
line-height: ${status.heights[ri]}px;
|
||||||
background-color: ${status.mergedConfig[row.rowIndex % 2 === 0 ? 'evenRowBGC' : 'oddRowBGC']};
|
background-color: ${status.mergedConfig[row.rowIndex % 2 === 0 ? 'evenRowBGC' : 'oddRowBGC']};
|
||||||
`">
|
`"
|
||||||
<div class="ceil" v-for="(ceil, ci) in row.ceils" :key="`${ceil}${ri}${ci}`"
|
>
|
||||||
:style="`width: ${status.widths[ci]}px;`" :align="status.aligns[ci]" v-html="ceil" />
|
<div
|
||||||
|
class="ceil"
|
||||||
|
v-for="(ceil, ci) in row.ceils"
|
||||||
|
:key="`${ceil}${ri}${ci}`"
|
||||||
|
:style="`width: ${status.widths[ci]}px;`"
|
||||||
|
:align="status.aligns[ci]"
|
||||||
|
v-html="ceil"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -35,8 +58,8 @@ import cloneDeep from 'lodash/cloneDeep'
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<CreateComponentType>,
|
type: Object as PropType<CreateComponentType>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 这里能拿到图表宽高等
|
// 这里能拿到图表宽高等
|
||||||
@ -138,11 +161,13 @@ const status = reactive({
|
|||||||
mergedConfig: props.chartConfig.option,
|
mergedConfig: props.chartConfig.option,
|
||||||
header: [],
|
header: [],
|
||||||
rowsData: [],
|
rowsData: [],
|
||||||
rows: [{
|
rows: [
|
||||||
ceils: [],
|
{
|
||||||
rowIndex: 0,
|
ceils: [],
|
||||||
scroll: 0
|
rowIndex: 0,
|
||||||
}],
|
scroll: 0
|
||||||
|
}
|
||||||
|
],
|
||||||
widths: [],
|
widths: [],
|
||||||
heights: [0],
|
heights: [0],
|
||||||
avgHeight: 0,
|
avgHeight: 0,
|
||||||
@ -163,7 +188,7 @@ const calcData = () => {
|
|||||||
animation(true)
|
animation(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(()=> {
|
onMounted(() => {
|
||||||
calcData()
|
calcData()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -185,19 +210,21 @@ const calcHeaderData = () => {
|
|||||||
const calcRowsData = () => {
|
const calcRowsData = () => {
|
||||||
let { dataset, index, headerBGC, rowNum } = status.mergedConfig
|
let { dataset, index, headerBGC, rowNum } = status.mergedConfig
|
||||||
if (index) {
|
if (index) {
|
||||||
dataset = dataset.map((row:any, i:number) => {
|
dataset = dataset.map((row: any, i: number) => {
|
||||||
row = [...row]
|
row = [...row]
|
||||||
const indexTag = `<span class="index" style="background-color: ${headerBGC};border-radius: 3px;padding: 0px 3px;">${i + 1}</span>`
|
const indexTag = `<span class="index" style="background-color: ${headerBGC};border-radius: 3px;padding: 0px 3px;">${
|
||||||
|
i + 1
|
||||||
|
}</span>`
|
||||||
row.unshift(indexTag)
|
row.unshift(indexTag)
|
||||||
return row
|
return row
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
dataset = dataset.map((ceils:any, i:number) => ({ ceils, rowIndex: i }))
|
dataset = dataset.map((ceils: any, i: number) => ({ ceils, rowIndex: i }))
|
||||||
const rowLength = dataset.length
|
const rowLength = dataset.length
|
||||||
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
||||||
dataset = [...dataset, ...dataset]
|
dataset = [...dataset, ...dataset]
|
||||||
}
|
}
|
||||||
dataset = dataset.map((d:any, i:number) => ({ ...d, scroll: i }))
|
dataset = dataset.map((d: any, i: number) => ({ ...d, scroll: i }))
|
||||||
|
|
||||||
status.rowsData = dataset
|
status.rowsData = dataset
|
||||||
status.rows = dataset
|
status.rows = dataset
|
||||||
@ -206,7 +233,7 @@ const calcRowsData = () => {
|
|||||||
const calcWidths = () => {
|
const calcWidths = () => {
|
||||||
const { mergedConfig, rowsData } = status
|
const { mergedConfig, rowsData } = status
|
||||||
const { columnWidth, header } = mergedConfig
|
const { columnWidth, header } = mergedConfig
|
||||||
const usedWidth = columnWidth.reduce((all:any, ws:number) => all + ws, 0)
|
const usedWidth = columnWidth.reduce((all: any, ws: number) => all + ws, 0)
|
||||||
let columnNum = 0
|
let columnNum = 0
|
||||||
if (rowsData[0]) {
|
if (rowsData[0]) {
|
||||||
columnNum = (rowsData[0] as any).ceils.length
|
columnNum = (rowsData[0] as any).ceils.length
|
||||||
@ -254,7 +281,7 @@ const animation = async (start = false) => {
|
|||||||
const rowLength = rowsData.length
|
const rowLength = rowsData.length
|
||||||
if (rowNum >= rowLength) return
|
if (rowNum >= rowLength) return
|
||||||
if (start) {
|
if (start) {
|
||||||
await new Promise(resolve => setTimeout(resolve, waitTime*1000))
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|
||||||
if (updater !== status.updater) return
|
if (updater !== status.updater) return
|
||||||
}
|
}
|
||||||
const animationNum = carousel === 'single' ? 1 : rowNum
|
const animationNum = carousel === 'single' ? 1 : rowNum
|
||||||
@ -269,7 +296,7 @@ const animation = async (start = false) => {
|
|||||||
const back = animationIndex - rowLength
|
const back = animationIndex - rowLength
|
||||||
if (back >= 0) animationIndex = back
|
if (back >= 0) animationIndex = back
|
||||||
status.animationIndex = animationIndex
|
status.animationIndex = animationIndex
|
||||||
status.animationHandler = setTimeout(animation, waitTime*1000 - 300) as any
|
status.animationHandler = setTimeout(animation, waitTime * 1000 - 300) as any
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopAnimation = () => {
|
const stopAnimation = () => {
|
||||||
@ -279,9 +306,13 @@ const stopAnimation = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onRestart = async () => {
|
const onRestart = async () => {
|
||||||
if (!status.mergedConfig) return
|
try {
|
||||||
stopAnimation()
|
if (!status.mergedConfig) return
|
||||||
calcData()
|
stopAnimation()
|
||||||
|
calcData()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -304,7 +335,7 @@ watch(
|
|||||||
() => {
|
() => {
|
||||||
onRestart()
|
onRestart()
|
||||||
},
|
},
|
||||||
{deep:true}
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
// 数据更新 (默认更新 dataset,若更新之后有其它操作,可添加回调函数)
|
// 数据更新 (默认更新 dataset,若更新之后有其它操作,可添加回调函数)
|
||||||
@ -316,7 +347,6 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (resData: any[]) => {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stopAnimation()
|
stopAnimation()
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user