feat: 新增 border 样式修改,修改全部设置引入方式

This commit is contained in:
MTrun 2022-03-26 15:36:52 +08:00
parent 822fbbcd24
commit caa403a8dc
11 changed files with 63 additions and 30 deletions

View File

@ -3,6 +3,7 @@ import { BarCommonConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
export const includes = ['legend', 'xAxis', 'yAxis']

View File

@ -36,20 +36,23 @@
</SettingItem>
</SettingItemBox>
</CollapseItem>
<!-- Echarts 全局设置 -->
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import {
GlobalSetting,
CollapseItem,
SettingItemBox,
SettingItem
} from '@/components/ChartItemSetting/index'
import { option } from './config'
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
type: Object as PropType<GlobalThemeJsonType>,
required: true
}
})

View File

@ -25,16 +25,19 @@
</SettingItem>
</SettingItemBox>
</CollapseItem>
<!-- Echarts 全局设置 -->
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/ChartItemSetting/index'
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/ChartItemSetting/index'
import { option } from './config'
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
type: Object as PropType<GlobalThemeJsonType>,
required: true
}
})

View File

@ -65,21 +65,24 @@
</SettingItem>
</SettingItemBox>
</CollapseItem>
<!-- Echarts 全局设置 -->
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { lineConf } from '@/packages/chartConfiguration/echarts/index'
import {
GlobalSetting,
CollapseItem,
SettingItemBox,
SettingItem
} from '@/components/ChartItemSetting/index'
import { option } from './config'
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
type: Object as PropType<GlobalThemeJsonType>,
required: true
}
})

View File

@ -1,6 +1,18 @@
<template>
<!-- Echarts 全局设置 -->
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
import { GlobalSetting } from '@/components/ChartItemSetting/index'
const props = defineProps({
optionData: {
type: Object as PropType<GlobalThemeJsonType>,
required: true
}
})
console.log(props.optionData)
</script>

View File

@ -3,10 +3,12 @@ import { CreateComponentType } from '@/packages/index.d'
import {BorderCommonConfig} from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
colors: ['#6586ec', '#2cf7fe']
}
export default class Config extends publicConfig implements CreateComponentType {
public key = BorderCommonConfig.key
public chartConfig = cloneDeep(BorderCommonConfig)
public borderOptions = {
colors: ['#6586ec', '#2cf7fe']
}
public option = option
}

View File

@ -1,18 +1,26 @@
<template>
<CollapseItem name="颜色" :expanded="true">
<!-- <SettingItemBox
name="图形"
v-for="(item, index) in optionData.borderOptions.colors"
<CollapseItem name="边框" :expanded="true">
<SettingItemBox
:name="`颜色-${index + 1}`"
v-for="(item, index) in optionData.colors"
:key="index"
>
<SettingItem :name="`颜色-${index + 1}`">
<SettingItem name="颜色">
<n-color-picker
size="small"
:modes="['hex']"
v-model:value="optionData.borderOptions.colors[index]"
v-model:value="optionData.colors[index]"
></n-color-picker>
</SettingItem>
</SettingItemBox> -->
<SettingItem>
<n-button
size="small"
@click="optionData.colors[index] = option.colors[index]"
>
恢复默认
</n-button>
</SettingItem>
</SettingItemBox>
</CollapseItem>
</template>
@ -23,11 +31,11 @@ import {
SettingItemBox,
SettingItem
} from '@/components/ChartItemSetting/index'
import Config from './config'
import { option } from './config'
const props = defineProps({
optionData: {
type: Object as PropType<Config>,
type: Object as PropType<typeof option>,
required: true
}
})

View File

@ -30,9 +30,7 @@
<path
fill="transparent"
:stroke="colors[1]"
:d="`M ${w - 5} ${h - 30} L ${w - 5} ${h - 5} L ${
w - 30
} ${h - 5}`"
:d="`M ${w - 5} ${h - 30} L ${w - 5} ${h - 5} L ${w - 30} ${h - 5}`"
/>
</svg>
@ -43,18 +41,21 @@
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { PropType, toRefs, computed } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
},
}
})
const { w, h } = toRefs(props.chartConfig.attr)
const { colors } = toRefs(props.chartConfig.borderOptions)
const colors = computed(() => {
return props.chartConfig.option?.colors
})
</script>
<style lang="scss" scoped></style>

View File

@ -36,8 +36,7 @@ export interface PublicConfigType extends requestConfig {
export interface CreateComponentType extends PublicConfigType {
key: string
chartConfig: ConfigType
option?: GlobalThemeJsonType
[T: string]: any
option: GlobalThemeJsonType
}
// 获取组件实例类中某个key对应value类型的方法

View File

@ -83,5 +83,8 @@ export const chartColorsSearch = {
}
// 默认主题详细配置
export type GlobalThemeJsonType = typeof themeJson
type ThemeJsonType = typeof themeJson
export interface GlobalThemeJsonType extends Partial<ThemeJsonType> {
[T:string]: any
}
export const globalThemeJson = themeJson

View File

@ -10,13 +10,11 @@
<styles-setting :chartStyles="targetData.styles"></styles-setting>
<!-- 自定义配置项 -->
<component :is="targetData.chartConfig.conKey" :optionData="targetData.option"></component>
<!-- Echarts 全局设置 -->
<global-setting v-if="targetData.option" :optionData="targetData.option" :in-chart="true"></global-setting>
</div>
</template>
<script setup lang="ts">
import { GlobalSetting, NameSetting, PositionSetting, SizeSetting, StylesSetting } from '@/components/ChartItemSetting/index'
import { NameSetting, PositionSetting, SizeSetting, StylesSetting } from '@/components/ChartItemSetting/index'
import { useTargetData } from '../hooks/useTargetData.hook'
const { targetData, chartEditStore } = useTargetData()