feat: 新增线条配置

This commit is contained in:
奔跑的面条 2025-06-16 17:39:20 +08:00
parent a9bb5e5397
commit 076c174cb7
10 changed files with 292 additions and 9 deletions

View File

@ -7,7 +7,11 @@
<setting-item-box name="布局">
<setting-item name="位置">
<n-select v-model:value="optionData.label.position" size="small" :options="labelConfig.barPosition" />
<n-select
v-model:value="optionData.label.position"
size="small"
:options="positionOptions || labelConfig.barPosition"
/>
</setting-item>
<setting-item name="间距">
@ -33,6 +37,10 @@ defineProps({
optionData: {
type: Object as PropType<vChartGlobalThemeJsonType>,
required: true
},
positionOptions: {
type: Array,
required: false
}
})
</script>

View File

@ -0,0 +1,33 @@
<template>
<collapse-item name="线条" v-if="optionData.line">
<SettingItemBox name="样式">
<setting-item name="宽度">
<n-input-number v-model:value="optionData.line.style.lineWidth" size="small" :min="1"></n-input-number>
</setting-item>
<setting-item name="线条类型">
<n-select
v-model:value="optionData.line.style.curveType"
:options="styleConfig.curveType"
size="small"
></n-select>
</setting-item>
<setting-item name="末端样式">
<n-select v-model:value="optionData.line.style.lineCap" :options="styleConfig.lineCap" size="small"></n-select>
</setting-item>
</SettingItemBox>
</collapse-item>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { styleConfig } from '@/packages/chartConfiguration/vcharts/index'
defineProps({
optionData: {
type: Object as PropType<vChartGlobalThemeJsonType>,
required: true
}
})
</script>

View File

@ -0,0 +1,56 @@
<template>
<template v-if="optionData.point">
<collapse-item name="实心点(图元)">
<template #header>
<n-switch v-model:value="optionData.point.visible" size="small"></n-switch>
</template>
<setting-item-box name="样式">
<setting-item name="位置">
<n-select v-model:value="optionData.point.style.symbolType" size="small" :options="styleConfig.symbolType" />
</setting-item>
<setting-item name="大小">
<n-input-number v-model:value="optionData.point.style.size" :min="0" size="small" />
</setting-item>
<setting-item name="填充透明度">
<n-input-number v-model:value="optionData.point.style.fillOpacity" :step="0.1" :min="0" size="small" />
</setting-item>
<setting-item name="边框宽度">
<n-input-number v-model:value="optionData.point.style.lineWidth" :min="0" size="small" />
</setting-item>
<setting-item name="边框颜色">
<n-color-picker v-model:value="optionData.point.style.stroke" size="small" />
</setting-item>
<setting-item name="边框透明度">
<n-input-number v-model:value="optionData.point.style.strokeOpacity" :step="0.1" :min="0" size="small" />
</setting-item>
<setting-item name="偏移X">
<n-input-number v-model:value="optionData.point.style.dx" :min="0" size="small" />
</setting-item>
<setting-item name="偏移Y">
<n-input-number v-model:value="optionData.point.style.dy" :min="0" size="small" />
</setting-item>
</setting-item-box>
</collapse-item>
</template>
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { styleConfig } from '@/packages/chartConfiguration/vcharts/index'
import FontStyle from './common/FontStyle.vue'
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
defineProps({
optionData: {
type: Object as PropType<vChartGlobalThemeJsonType>,
required: true
},
positionOptions: {
type: Array,
required: false
}
})
</script>

View File

@ -2,5 +2,7 @@ import VChartGlobalSetting from './VChartGlobalSetting.vue'
import Axis from './Axis.vue'
import Label from './Label.vue'
import Bar from './Bar.vue'
import Line from './Line.vue'
import Point from './Point.vue'
export { VChartGlobalSetting, Axis, Label, Bar }
export { VChartGlobalSetting, Axis, Label, Bar, Line, Point }

View File

@ -78,5 +78,43 @@ export const labelConfig = {
label: '底部-左',
value: 'bottom-left'
}
],
linePosition: [
{
label: '顶部',
value: 'top'
},
{
label: '底部',
value: 'bottom'
},
{
label: '左侧',
value: 'left'
},
{
label: '右侧',
value: 'right'
},
{
label: '顶部-右',
value: 'top-right'
},
{
label: '顶部-左',
value: 'top-left'
},
{
label: '底部-右',
value: 'bottom-right'
},
{
label: '底部-左',
value: 'bottom-left'
},
{
label: '居中',
value: 'center'
}
]
}

View File

@ -36,5 +36,115 @@ export const styleConfig = {
label: '格子',
value: 'grid'
}
],
curveType: [
{
label: '线性',
value: 'linear'
},
{
label: '平滑',
value: 'monotone'
},
{
label: '平滑趋近X',
value: 'monotoneX'
},
{
label: '台阶',
value: 'step'
},
{
label: '连线闭合',
value: 'catmullRom'
},
{
label: '顺滑闭合',
value: 'catmullRomClosed'
}
],
lineCap: [
{
label: '默认',
value: 'butt'
},
{
label: '圆形',
value: 'round'
},
{
label: '方形',
value: 'square'
}
],
symbolType: [
{
label: '圆形',
value: 'circle'
},
{
label: '方形',
value: 'rect'
},
{
label: '菱形',
value: 'diamond'
},
{
label: '三角形',
value: 'square'
},
{
label: '指向向上',
value: 'arrow'
},
{
label: '指向向左',
value: 'arrow2Left'
},
{
label: '箭头向右',
value: 'arrow2Right'
},
{
label: '瘦箭头向上',
value: 'wedge'
},
{
label: '箭头向上',
value: 'triangle'
},
{
label: '箭头向下',
value: 'triangleDown'
},
{
label: '箭头向右',
value: 'triangleRight'
},
{
label: '箭头向左',
value: 'triangleLeft'
},
{
label: '星星',
value: 'star'
},
{
label: 'y字形物',
value: 'wye'
},
{
label: '矩形',
value: 'rect'
},
{
label: '圆角矩形',
value: 'rectRound'
},
{
label: '扁平矩形',
value: 'roundLine'
}
]
}

View File

@ -22,7 +22,7 @@
import { PropType } from 'vue'
import { VChartGlobalSetting, Axis, Label, Bar } from '@/components/Pages/VChartItemSetting'
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting'
defineProps({
optionData: {

View File

@ -5,9 +5,9 @@ import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
import data from './data.json'
import cloneDeep from 'lodash/cloneDeep'
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
import { ILineOption } from '../../index.d'
import { ChatCategoryEnum, ILineOption } from '../../index.d'
export const includes = ['legends', 'tooltip']
export const includes = ['legends', 'tooltip', 'label', 'line', 'point']
export const option: ILineOption & { dataset?: any } = {
// 图表配置
type: 'line',
@ -16,8 +16,10 @@ export const option: ILineOption & { dataset?: any } = {
yField: 'value',
seriesField: 'country',
stack: true,
// 开启百分比
percent: false,
// 业务配置后续会被转换为图表spec)
category: VChartLineConfig.category,
category: VChartLineConfig.category as ChatCategoryEnum.LINE,
xAxis: {
name: 'x轴',
...axisThemeJson,
@ -25,7 +27,7 @@ export const option: ILineOption & { dataset?: any } = {
...axisThemeJson.grid,
visible: false
}
},
} as any,
yAxis: {
name: 'y轴',
...axisThemeJson,
@ -36,7 +38,7 @@ export const option: ILineOption & { dataset?: any } = {
lineDash: [3, 3]
}
}
}
} as any
}
export default class Config extends PublicConfigClass implements CreateComponentType {

View File

@ -3,12 +3,26 @@
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
<Axis :axis="optionData.xAxis"></Axis>
<Axis :axis="optionData.yAxis"></Axis>
<!-- 开启百分比 -->
<CollapseItem name="百分比堆叠">
<SettingItemBox name="配置" alone>
<n-space>
<span>开启百分比堆叠</span>
<n-switch v-model:value="optionData.percent" size="small"></n-switch>
</n-space>
</SettingItemBox>
</CollapseItem>
<Line :optionData="optionData"></Line>
<Label :optionData="optionData" :positionOptions="labelConfig.linePosition"></Label>
<Point :optionData="optionData"></Point>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
import { VChartGlobalSetting, Axis, Label, Line, Point } from '@/components/Pages/VChartItemSetting'
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting'
import { labelConfig } from '@/packages/chartConfiguration/vcharts/index'
defineProps({
optionData: {

View File

@ -98,5 +98,25 @@
"opacity": 1,
"texture": ""
}
},
"line": {
"style": {
"lineWidth": 1,
"lineCap": "butt",
"curveType": "linear"
}
},
"point": {
"visible": true,
"style": {
"symbolType": "circle",
"size": 10,
"fillOpacity": 1,
"lineWidth": 2,
"stroke": "#ffffff",
"strokeOpacity": 1,
"dx": 0,
"dy": 0
}
}
}