diff --git a/src/assets/images/chart/charts/line.png b/src/assets/images/chart/charts/line.png index c67a8401..75217dbd 100644 Binary files a/src/assets/images/chart/charts/line.png and b/src/assets/images/chart/charts/line.png differ diff --git a/src/assets/images/chart/charts/line_linear_single.png b/src/assets/images/chart/charts/line_linear_single.png new file mode 100644 index 00000000..c67a8401 Binary files /dev/null and b/src/assets/images/chart/charts/line_linear_single.png differ diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index d13c60e7..0462e181 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -62,16 +62,15 @@ export const useChartDataFetch = ( if (res && res.data) { try { const filter = targetComponent.filter + // eCharts 组件配合 vChart 库更新方式 + if (chartFrame === ChartFrameEnum.ECHARTS) { + if (vChartRef.value) { + vChartRef.value.setOption({ dataset: newFunctionHandle(res.data, filter) }) + } + } // 更新回调函数 if (updateCallback) { updateCallback(newFunctionHandle(res.data, filter)) - } else { - // eCharts 组件配合 vChart 库更新方式 - if (chartFrame === ChartFrameEnum.ECHARTS) { - if (vChartRef.value) { - vChartRef.value.setOption({ dataset: newFunctionHandle(res.data, filter) }) - } - } } } catch (error) { console.error(error) diff --git a/src/packages/components/Charts/Bars/BarCommon/config.ts b/src/packages/components/Charts/Bars/BarCommon/config.ts index 187ff852..190c605f 100644 --- a/src/packages/components/Charts/Bars/BarCommon/config.ts +++ b/src/packages/components/Charts/Bars/BarCommon/config.ts @@ -6,6 +6,15 @@ import dataJson from './data.json' export const includes = ['legend', 'xAxis', 'yAxis'] +export const seriesItem = { + type: 'bar', + barWidth: null, + itemStyle: { + color: null, + borderRadius: 0 + } +} + export const option = { tooltip: { show: true, @@ -27,24 +36,7 @@ export const option = { type: 'value' }, dataset: { ...dataJson }, - series: [ - { - type: 'bar', - barWidth: null, - itemStyle: { - color: null, - borderRadius: 0 - } - }, - { - type: 'bar', - barWidth: null, - itemStyle: { - color: null, - borderRadius: 0 - } - } - ] + series: [seriesItem, seriesItem] } export default class Config extends publicConfig implements CreateComponentType { diff --git a/src/packages/components/Charts/Bars/BarCommon/index.vue b/src/packages/components/Charts/Bars/BarCommon/index.vue index f6f9482c..b186a6d1 100644 --- a/src/packages/components/Charts/Bars/BarCommon/index.vue +++ b/src/packages/components/Charts/Bars/BarCommon/index.vue @@ -1,25 +1,29 @@ diff --git a/src/packages/components/Charts/Bars/BarCrossrange/config.ts b/src/packages/components/Charts/Bars/BarCrossrange/config.ts index 72569058..45f2191b 100644 --- a/src/packages/components/Charts/Bars/BarCrossrange/config.ts +++ b/src/packages/components/Charts/Bars/BarCrossrange/config.ts @@ -6,50 +6,40 @@ import dataJson from './data.json' export const includes = ['legend', 'xAxis', 'yAxis'] +export const seriesItem = { + type: 'bar', + barWidth: null, + itemStyle: { + color: null, + borderRadius: 0 + } +} + export const option = { tooltip: { show: true, trigger: 'axis', axisPointer: { show: true, - type: 'shadow', - }, + type: 'shadow' + } }, legend: { - show: true, + show: true }, xAxis: { show: true, type: 'value', - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], }, yAxis: { show: true, - type: 'category', + type: 'category' }, dataset: { ...dataJson }, - series: [ - { - type: 'bar', - barWidth: null, - itemStyle: { - color: null, - borderRadius: 0, - }, - }, - { - type: 'bar', - barWidth: null, - itemStyle: { - color: null, - borderRadius: 0, - }, - }, - ], + series: [seriesItem, seriesItem] } -export default class Config extends publicConfig - implements CreateComponentType { +export default class Config extends publicConfig implements CreateComponentType { public key = BarCrossrangeConfig.key public chartConfig = cloneDeep(BarCrossrangeConfig) // 图表配置项 diff --git a/src/packages/components/Charts/Bars/BarCrossrange/index.vue b/src/packages/components/Charts/Bars/BarCrossrange/index.vue index 165a697a..5e928ee0 100644 --- a/src/packages/components/Charts/Bars/BarCrossrange/index.vue +++ b/src/packages/components/Charts/Bars/BarCrossrange/index.vue @@ -1,24 +1,28 @@ diff --git a/src/packages/components/Charts/Lines/LineCommon/config.ts b/src/packages/components/Charts/Lines/LineCommon/config.ts index 92a42cfd..85858462 100644 --- a/src/packages/components/Charts/Lines/LineCommon/config.ts +++ b/src/packages/components/Charts/Lines/LineCommon/config.ts @@ -6,6 +6,18 @@ import dataJson from './data.json' export const includes = ['legend', 'xAxis', 'yAxis'] +export const seriesItem = { + type: 'line', + lineStyle: { + type: 'solid', + width: 3, + itemStyle: { + color: null, + borderRadius: 0 + } + } +} + export const option = { tooltip: { show: true, @@ -19,43 +31,17 @@ export const option = { }, xAxis: { show: true, - type: 'category', + type: 'category' }, yAxis: { show: true, type: 'value' }, dataset: { ...dataJson }, - series: [ - { - type: 'line', - lineStyle: { - type: 'solid', - width: 3, - color: { - type: 'linear', - colorStops: [ - { - offset: 0, - color: chartColorsSearch[defaultTheme][0] // 0% 处的颜色 - }, - { - offset: 1, - color: chartColorsSearch[defaultTheme][1] // 100% 处的颜色 - } - ], - globalCoord: false // 缺省为 false - }, - shadowColor: chartColorsSearch[defaultTheme][2], - shadowBlur: 10, - shadowOffsetY: 20 - }, - } - ] + series: [seriesItem, seriesItem] } -export default class Config extends publicConfig - implements CreateComponentType { +export default class Config extends publicConfig implements CreateComponentType { public key: string = LineCommonConfig.key public chartConfig = LineCommonConfig // 图表配置项 diff --git a/src/packages/components/Charts/Lines/LineCommon/config.vue b/src/packages/components/Charts/Lines/LineCommon/config.vue index 884d51f2..ade7666d 100644 --- a/src/packages/components/Charts/Lines/LineCommon/config.vue +++ b/src/packages/components/Charts/Lines/LineCommon/config.vue @@ -6,20 +6,6 @@ :expanded="true" > - - - - - - - - - - - - - - - - 去除阴影 - - - diff --git a/src/packages/components/Charts/Lines/LineCommon/data.json b/src/packages/components/Charts/Lines/LineCommon/data.json index b0dbe05f..a28d4ee7 100644 --- a/src/packages/components/Charts/Lines/LineCommon/data.json +++ b/src/packages/components/Charts/Lines/LineCommon/data.json @@ -1,33 +1,40 @@ { - "dimensions": ["product", "data1"], + "dimensions": ["product", "data1", "data2"], "source": [ { "product": "Mon", - "data1": 120 + "data1": 120, + "data2": 130 }, { "product": "Tue", - "data1": 200 + "data1": 200, + "data2": 130 }, { "product": "Wed", - "data1": 150 + "data1": 150, + "data2": 312 }, { "product": "Thu", - "data1": 80 + "data1": 80, + "data2": 268 }, { "product": "Fri", - "data1": 70 + "data1": 70, + "data2": 155 }, { "product": "Sat", - "data1": 110 + "data1": 110, + "data2": 117 }, { "product": "Sun", - "data1": 130 + "data1": 130, + "data2": 160 } ] } diff --git a/src/packages/components/Charts/Lines/LineCommon/index.vue b/src/packages/components/Charts/Lines/LineCommon/index.vue index e2f8f9d0..4af2be19 100644 --- a/src/packages/components/Charts/Lines/LineCommon/index.vue +++ b/src/packages/components/Charts/Lines/LineCommon/index.vue @@ -1,26 +1,29 @@ \ No newline at end of file + diff --git a/src/packages/components/Charts/Lines/LineGradientSingle/index.ts b/src/packages/components/Charts/Lines/LineGradientSingle/index.ts index 0e21e0cd..d2ff3e84 100644 --- a/src/packages/components/Charts/Lines/LineGradientSingle/index.ts +++ b/src/packages/components/Charts/Lines/LineGradientSingle/index.ts @@ -6,7 +6,7 @@ export const LineGradientSingleConfig: ConfigType = { key: 'LineGradientSingle', chartKey: 'VLineGradientSingle', conKey: 'VCLineGradientSingle', - title: '单折线面积图', + title: '单折线渐变面积图', category: ChatCategoryEnum.LINE, categoryName: ChatCategoryEnumName.LINE, package: PackagesCategoryEnum.CHARTS, diff --git a/src/packages/components/Charts/Lines/LineGradientSingle/index.vue b/src/packages/components/Charts/Lines/LineGradientSingle/index.vue index 877e4407..a2e3dd9a 100644 --- a/src/packages/components/Charts/Lines/LineGradientSingle/index.vue +++ b/src/packages/components/Charts/Lines/LineGradientSingle/index.vue @@ -1,10 +1,5 @@ @@ -37,14 +32,7 @@ const props = defineProps({ } }) -use([ - DatasetComponent, - CanvasRenderer, - LineChart, - GridComponent, - TooltipComponent, - LegendComponent, -]) +use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent]) const chartEditStore = useChartEditStore() const option = reactive({ @@ -52,32 +40,41 @@ const option = reactive({ }) // 渐变色处理 -watch(() => chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => { - if (!isPreview()) { - const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme] - props.chartConfig.option.series.forEach((value: any, index: number) => { - value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [ - { - offset: 0, - color: themeColor[3] - }, - { - offset: 1, - color: 'rgba(0,0,0, 0)' - } - ]) - }) +watch( + () => chartEditStore.getEditCanvasConfig.chartThemeColor, + (newColor: keyof typeof chartColorsSearch) => { + if (!isPreview()) { + const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme] + props.chartConfig.option.series.forEach((value: any, index: number) => { + value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [ + { + offset: 0, + color: themeColor[3] + }, + { + offset: 1, + color: 'rgba(0,0,0, 0)' + } + ]) + }) + } + option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) + props.chartConfig.option = option.value + }, + { + immediate: true } - option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) - props.chartConfig.option = option.value -}, { - immediate: true -}) +) - -watch(() => props.chartConfig.option.dataset, () => { - option.value = props.chartConfig.option -}) +watch( + () => props.chartConfig.option.dataset, + () => { + option.value = props.chartConfig.option + }, + { + deep: false + } +) const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore) diff --git a/src/packages/components/Charts/Lines/LineGradients/index.ts b/src/packages/components/Charts/Lines/LineGradients/index.ts index 347ac0ce..331e2579 100644 --- a/src/packages/components/Charts/Lines/LineGradients/index.ts +++ b/src/packages/components/Charts/Lines/LineGradients/index.ts @@ -6,7 +6,7 @@ export const LineGradientsConfig: ConfigType = { key: 'LineGradients', chartKey: 'VLineGradients', conKey: 'VCLineGradients', - title: '双折线面积图', + title: '双折线渐变面积图', category: ChatCategoryEnum.LINE, categoryName: ChatCategoryEnumName.LINE, package: PackagesCategoryEnum.CHARTS, diff --git a/src/packages/components/Charts/Lines/LineGradients/index.vue b/src/packages/components/Charts/Lines/LineGradients/index.vue index bb8b4f8a..bc134641 100644 --- a/src/packages/components/Charts/Lines/LineGradients/index.vue +++ b/src/packages/components/Charts/Lines/LineGradients/index.vue @@ -31,14 +31,7 @@ const props = defineProps({ } }) -use([ - DatasetComponent, - CanvasRenderer, - LineChart, - GridComponent, - TooltipComponent, - LegendComponent, -]) +use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent]) const chartEditStore = useChartEditStore() const option = reactive({ @@ -46,31 +39,38 @@ const option = reactive({ }) // 渐变色处理 -watch(() => chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => { - if (!isPreview()) { - const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme] - 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: 1, - color: 'rgba(0,0,0, 0)' - } - ]) - }) +watch( + () => chartEditStore.getEditCanvasConfig.chartThemeColor, + (newColor: keyof typeof chartColorsSearch) => { + if (!isPreview()) { + const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme] + 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: 1, + color: 'rgba(0,0,0, 0)' + } + ]) + }) + } + option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) + props.chartConfig.option = option.value + }, + { + immediate: true } - option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) - props.chartConfig.option = option.value -}, { - immediate: true -}) +) -watch(() => props.chartConfig.option.dataset, () => { - option.value = props.chartConfig.option -}) +watch( + () => props.chartConfig.option.dataset, + () => { + option.value = props.chartConfig.option + } +) const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore) diff --git a/src/packages/components/Charts/Lines/LineLinearSingle/config.ts b/src/packages/components/Charts/Lines/LineLinearSingle/config.ts new file mode 100644 index 00000000..6d256c92 --- /dev/null +++ b/src/packages/components/Charts/Lines/LineLinearSingle/config.ts @@ -0,0 +1,63 @@ +import { echartOptionProfixHandle, publicConfig } from '@/packages/public' +import { LineLinearSingleConfig } from './index' +import { CreateComponentType } from '@/packages/index.d' +import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index' +import dataJson from './data.json' + +export const includes = ['legend', 'xAxis', 'yAxis'] + +export const option = { + tooltip: { + show: true, + trigger: 'axis', + axisPointer: { + type: 'line' + } + }, + legend: { + show: true + }, + xAxis: { + show: true, + type: 'category', + }, + yAxis: { + show: true, + type: 'value' + }, + dataset: { ...dataJson }, + series: [ + { + type: 'line', + lineStyle: { + type: 'solid', + width: 3, + color: { + type: 'linear', + colorStops: [ + { + offset: 0, + color: chartColorsSearch[defaultTheme][0] // 0% 处的颜色 + }, + { + offset: 1, + color: chartColorsSearch[defaultTheme][1] // 100% 处的颜色 + } + ], + globalCoord: false // 缺省为 false + }, + shadowColor: chartColorsSearch[defaultTheme][2], + shadowBlur: 10, + shadowOffsetY: 20 + }, + } + ] +} + +export default class Config extends publicConfig + implements CreateComponentType { + public key: string = LineLinearSingleConfig.key + public chartConfig = LineLinearSingleConfig + // 图表配置项 + public option = echartOptionProfixHandle(option, includes) +} diff --git a/src/packages/components/Charts/Lines/LineLinearSingle/config.vue b/src/packages/components/Charts/Lines/LineLinearSingle/config.vue new file mode 100644 index 00000000..18801629 --- /dev/null +++ b/src/packages/components/Charts/Lines/LineLinearSingle/config.vue @@ -0,0 +1,86 @@ + + + diff --git a/src/packages/components/Charts/Lines/LineLinearSingle/data.json b/src/packages/components/Charts/Lines/LineLinearSingle/data.json new file mode 100644 index 00000000..b0dbe05f --- /dev/null +++ b/src/packages/components/Charts/Lines/LineLinearSingle/data.json @@ -0,0 +1,33 @@ +{ + "dimensions": ["product", "data1"], + "source": [ + { + "product": "Mon", + "data1": 120 + }, + { + "product": "Tue", + "data1": 200 + }, + { + "product": "Wed", + "data1": 150 + }, + { + "product": "Thu", + "data1": 80 + }, + { + "product": "Fri", + "data1": 70 + }, + { + "product": "Sat", + "data1": 110 + }, + { + "product": "Sun", + "data1": 130 + } + ] +} diff --git a/src/packages/components/Charts/Lines/LineLinearSingle/index.ts b/src/packages/components/Charts/Lines/LineLinearSingle/index.ts new file mode 100644 index 00000000..1b774bde --- /dev/null +++ b/src/packages/components/Charts/Lines/LineLinearSingle/index.ts @@ -0,0 +1,15 @@ +import image from '@/assets/images/chart/charts/line_linear_single.png' +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' + +export const LineLinearSingleConfig: ConfigType = { + key: 'LineLinearSingle', + chartKey: 'VLineLinearSingle', + conKey: 'VCLineLinearSingle', + title: '单折线渐变图', + category: ChatCategoryEnum.LINE, + categoryName: ChatCategoryEnumName.LINE, + package: PackagesCategoryEnum.CHARTS, + chartFrame: ChartFrameEnum.ECHARTS, + image +} diff --git a/src/packages/components/Charts/Lines/LineLinearSingle/index.vue b/src/packages/components/Charts/Lines/LineLinearSingle/index.vue new file mode 100644 index 00000000..4dd94fa8 --- /dev/null +++ b/src/packages/components/Charts/Lines/LineLinearSingle/index.vue @@ -0,0 +1,74 @@ + + + diff --git a/src/packages/components/Charts/Lines/index.ts b/src/packages/components/Charts/Lines/index.ts index 7ff11929..e8c37e00 100644 --- a/src/packages/components/Charts/Lines/index.ts +++ b/src/packages/components/Charts/Lines/index.ts @@ -1,5 +1,6 @@ import { LineCommonConfig } from './LineCommon/index' +import { LineLinearSingleConfig } from './LineLinearSingle/index' import { LineGradientSingleConfig } from './LineGradientSingle/index' import { LineGradientsConfig } from './LineGradients/index' -export default [LineCommonConfig, LineGradientSingleConfig, LineGradientsConfig] +export default [LineCommonConfig, LineLinearSingleConfig, LineGradientSingleConfig, LineGradientsConfig] diff --git a/src/packages/components/Charts/Maps/MapChina/index.vue b/src/packages/components/Charts/Maps/MapChina/index.vue index 39fe0c59..5399a5b8 100644 --- a/src/packages/components/Charts/Maps/MapChina/index.vue +++ b/src/packages/components/Charts/Maps/MapChina/index.vue @@ -82,7 +82,8 @@ watch( dataSetHandle(newData) }, { - immediate: true + immediate: true, + deep: false } ) diff --git a/src/packages/components/Charts/Mores/Process/index.vue b/src/packages/components/Charts/Mores/Process/index.vue index fb0b7b7f..f23db2d7 100644 --- a/src/packages/components/Charts/Mores/Process/index.vue +++ b/src/packages/components/Charts/Mores/Process/index.vue @@ -58,6 +58,9 @@ watch( () => props.chartConfig.option.dataset, (newData: any) => { option.dataset = toNumber(newData, 2) + }, + { + deep: false } ) // 预览更新 diff --git a/src/packages/components/Charts/Mores/Radar/data.json b/src/packages/components/Charts/Mores/Radar/data.json index 74574954..3ee8ebc0 100644 --- a/src/packages/components/Charts/Mores/Radar/data.json +++ b/src/packages/components/Charts/Mores/Radar/data.json @@ -9,12 +9,12 @@ ], "seriesData": [ { - "value": [4200, 3000, 20000, 35000, 50000, 18000], - "name": "data1" + "name": "data1", + "value": [4200, 3000, 20000, 35000, 50000, 18000] }, { - "value": [5000, 14000, 28000, 26000, 42000, 21000], - "name": "data2" + "name": "data2", + "value": [5000, 14000, 28000, 26000, 42000, 21000] } ] } diff --git a/src/packages/components/Charts/Mores/Radar/index.vue b/src/packages/components/Charts/Mores/Radar/index.vue index 4ef3c805..5886ec1c 100644 --- a/src/packages/components/Charts/Mores/Radar/index.vue +++ b/src/packages/components/Charts/Mores/Radar/index.vue @@ -59,7 +59,7 @@ watch( dataSetHandle(newData) }, { - immediate: true + deep: false } ) diff --git a/src/packages/components/Charts/Mores/WaterPolo/index.vue b/src/packages/components/Charts/Mores/WaterPolo/index.vue index 270f0137..14112d94 100644 --- a/src/packages/components/Charts/Mores/WaterPolo/index.vue +++ b/src/packages/components/Charts/Mores/WaterPolo/index.vue @@ -79,7 +79,8 @@ watch( option.value = props.chartConfig.option }, { - immediate: true + immediate: true, + deep: false } ) diff --git a/src/packages/components/Charts/Pies/PieCircle/index.vue b/src/packages/components/Charts/Pies/PieCircle/index.vue index 4309e02b..61c50049 100644 --- a/src/packages/components/Charts/Pies/PieCircle/index.vue +++ b/src/packages/components/Charts/Pies/PieCircle/index.vue @@ -50,7 +50,8 @@ watch( () => props.chartConfig.option.dataset, newData => dataHandle(newData), { - immediate: true + immediate: true, + deep: false } ) diff --git a/src/packages/components/Decorates/Mores/Number/index.vue b/src/packages/components/Decorates/Mores/Number/index.vue index fbb8be00..4b6169b2 100644 --- a/src/packages/components/Decorates/Mores/Number/index.vue +++ b/src/packages/components/Decorates/Mores/Number/index.vue @@ -6,8 +6,13 @@ - + diff --git a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataRequest/index.vue b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataRequest/index.vue index 36fb25b2..258577ad 100644 --- a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataRequest/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataRequest/index.vue @@ -33,7 +33,7 @@ import { useTargetData } from '../../../hooks/useTargetData.hook' import { RequestGlobalConfig } from './components/RequestGlobalConfig' import { RequestTargetConfig } from './components/RequestTargetConfig' -const emit = defineEmits(['update:modelShow']) +const emit = defineEmits(['update:modelShow', 'sendHandle']) const { targetData } = useTargetData() // 解构基础配置 @@ -50,6 +50,7 @@ defineProps({ const closeHandle = () => { emit('update:modelShow', false) + emit('sendHandle') }