mirror of
https://gitee.com/dromara/go-view.git
synced 2025-06-18 19:59:14 +08:00
feat: 新增柱状图配置
This commit is contained in:
parent
8bb65e57f4
commit
99366efc8c
@ -211,7 +211,7 @@ const createOrUpdateChart = (
|
||||
const spec = transformHandler[chartProps.category || '']?.(chartProps)
|
||||
chart.updateSpec({ ...spec, data: toRaw(chartProps.dataset), dataset: undefined }, false, undefined, {
|
||||
change: false,
|
||||
reMake: false,
|
||||
reMake: true,
|
||||
reAnimate: true
|
||||
})
|
||||
return true
|
||||
|
@ -15,15 +15,15 @@
|
||||
<FontStyle :style="toRefs(axis.unit.style)"></FontStyle>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="轴标签">
|
||||
<setting-item name="可见性">
|
||||
<setting-item v-if="axis.label" name="可见性">
|
||||
<n-space>
|
||||
<n-switch v-model:value="axis.label.visible" size="small"></n-switch>
|
||||
</n-space>
|
||||
</setting-item>
|
||||
<setting-item name="角度">
|
||||
<setting-item v-if="axis.label" name="角度">
|
||||
<n-input-number v-model:value="axis.label.style.angle" :min="0" :max="360" size="small" />
|
||||
</setting-item>
|
||||
<FontStyle :style="toRefs(axis.label.style)"></FontStyle>
|
||||
<FontStyle v-if="axis.label" :style="toRefs(axis.label.style)"></FontStyle>
|
||||
</setting-item-box>
|
||||
<setting-item-box name="轴标题">
|
||||
<setting-item name="可见性">
|
||||
|
52
src/components/Pages/VChartItemSetting/Bar.vue
Normal file
52
src/components/Pages/VChartItemSetting/Bar.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<template v-if="optionData.bar">
|
||||
<collapse-item name="柱体">
|
||||
<SettingItemBox name="样式">
|
||||
<setting-item v-if="'width' in optionData.bar.style" name="宽度">
|
||||
<n-input-number v-model:value="optionData.bar.style.width" size="small" :min="1"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item v-if="'height' in (optionData.bar.style as any)" name="高度">
|
||||
<n-input-number v-model:value="(optionData.bar.style as any).height" size="small" :min="1"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="圆角大小">
|
||||
<n-input-number v-model:value="optionData.bar.style.cornerRadius" size="small" :min="0"></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="填充透明度">
|
||||
<n-input-number
|
||||
v-model:value="optionData.bar.style.fillOpacity"
|
||||
:step="0.1"
|
||||
size="small"
|
||||
:min="0"
|
||||
:max="1"
|
||||
></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="整体透明度">
|
||||
<n-input-number
|
||||
v-model:value="optionData.bar.style.opacity"
|
||||
:step="0.1"
|
||||
size="small"
|
||||
:min="0"
|
||||
:max="1"
|
||||
></n-input-number>
|
||||
</setting-item>
|
||||
<setting-item name="纹理类型">
|
||||
<n-select v-model:value="optionData.bar.style.texture" :options="styleConfig.texture" size="small"></n-select>
|
||||
</setting-item>
|
||||
</SettingItemBox>
|
||||
</collapse-item>
|
||||
</template>
|
||||
</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>
|
38
src/components/Pages/VChartItemSetting/Label.vue
Normal file
38
src/components/Pages/VChartItemSetting/Label.vue
Normal file
@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<template v-if="optionData.label">
|
||||
<collapse-item name="标签">
|
||||
<template #header>
|
||||
<n-switch v-model:value="optionData.label.visible" size="small"></n-switch>
|
||||
</template>
|
||||
|
||||
<setting-item-box name="布局">
|
||||
<setting-item name="位置">
|
||||
<n-select v-model:value="optionData.label.position" size="small" :options="labelConfig.barPosition" />
|
||||
</setting-item>
|
||||
|
||||
<setting-item name="间距">
|
||||
<n-input-number v-model:value="optionData.label.offset" :min="1" size="small" />
|
||||
</setting-item>
|
||||
</setting-item-box>
|
||||
|
||||
<setting-item-box name="字体">
|
||||
<FontStyle :style="toRefs(optionData.label.style)"></FontStyle>
|
||||
</setting-item-box>
|
||||
</collapse-item>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType, toRefs } from 'vue'
|
||||
import { labelConfig } 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
|
||||
}
|
||||
})
|
||||
</script>
|
@ -1,4 +1,6 @@
|
||||
import VChartGlobalSetting from './VChartGlobalSetting.vue'
|
||||
import Axis from './Axis.vue'
|
||||
import Label from './Label.vue'
|
||||
import Bar from './Bar.vue'
|
||||
|
||||
export { VChartGlobalSetting, Axis }
|
||||
export { VChartGlobalSetting, Axis, Label, Bar }
|
||||
|
@ -20,5 +20,63 @@ export const labelConfig = {
|
||||
label: '内部-居中',
|
||||
value: 'inside-center'
|
||||
}
|
||||
],
|
||||
barPosition: [
|
||||
{
|
||||
label: '外部',
|
||||
value: 'outside'
|
||||
},
|
||||
{
|
||||
label: '内部',
|
||||
value: 'inside'
|
||||
},
|
||||
{
|
||||
label: '顶部',
|
||||
value: 'top'
|
||||
},
|
||||
{
|
||||
label: '底部',
|
||||
value: 'bottom'
|
||||
},
|
||||
{
|
||||
label: '左侧',
|
||||
value: 'left'
|
||||
},
|
||||
{
|
||||
label: '右侧',
|
||||
value: 'right'
|
||||
},
|
||||
{
|
||||
label: '内部-顶',
|
||||
value: 'inside-top'
|
||||
},
|
||||
{
|
||||
label: '内部-底',
|
||||
value: 'inside-bottom'
|
||||
},
|
||||
{
|
||||
label: '内部-右',
|
||||
value: 'inside-right'
|
||||
},
|
||||
{
|
||||
label: '内部-左',
|
||||
value: 'inside-left'
|
||||
},
|
||||
{
|
||||
label: '顶部-右',
|
||||
value: 'top-right'
|
||||
},
|
||||
{
|
||||
label: '顶部-左',
|
||||
value: 'top-left'
|
||||
},
|
||||
{
|
||||
label: '底部-右',
|
||||
value: 'bottom-right'
|
||||
},
|
||||
{
|
||||
label: '底部-左',
|
||||
value: 'bottom-left'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { ChatCategoryEnum, IBarOption } from '../../index.d'
|
||||
import { merge, cloneDeep } from 'lodash'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const includes = ['legends', 'tooltip', 'label', 'bar']
|
||||
export const option: IBarOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'bar',
|
||||
|
@ -3,11 +3,15 @@
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
<!-- 标签 -->
|
||||
<Label :optionData="optionData"></Label>
|
||||
<!-- 柱体 -->
|
||||
<Bar :optionData="optionData"></Bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { VChartGlobalSetting, Axis, Label, Bar } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
|
@ -6,8 +6,16 @@ import data from './data.json'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { ChatCategoryEnum, IBarOption } from '../../index.d'
|
||||
import { merge, cloneDeep } from 'lodash'
|
||||
import { vChartGlobalThemeJson } from '@/settings/vchartThemes'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
const barConfig = merge(cloneDeep(vChartGlobalThemeJson.bar), {
|
||||
style: {
|
||||
height: 10
|
||||
}
|
||||
})
|
||||
delete (barConfig.style as { width?: any }).width
|
||||
|
||||
export const includes = ['legends', 'tooltip', 'label']
|
||||
export const option: IBarOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'bar',
|
||||
@ -50,6 +58,9 @@ export const option: IBarOption & { dataset?: any } = {
|
||||
...axisThemeJson.grid.style
|
||||
}
|
||||
}
|
||||
},
|
||||
bar: {
|
||||
...barConfig
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,15 @@
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
<!-- 标签 -->
|
||||
<Label :optionData="optionData"></Label>
|
||||
<!-- 柱体 -->
|
||||
<Bar :optionData="optionData"></Bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { VChartGlobalSetting, Axis, Label, Bar } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
|
@ -6,8 +6,15 @@ import data from './data.json'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { ChatCategoryEnum, IBarOption } from '../../index.d'
|
||||
import { merge, cloneDeep } from 'lodash'
|
||||
import { vChartGlobalThemeJson } from '@/settings/vchartThemes'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
const barConfig = merge(cloneDeep(vChartGlobalThemeJson.bar), {
|
||||
style: {
|
||||
width: 15
|
||||
}
|
||||
})
|
||||
|
||||
export const includes = ['legends', 'tooltip', 'label']
|
||||
export const option: IBarOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'bar',
|
||||
@ -49,6 +56,9 @@ export const option: IBarOption & { dataset?: any } = {
|
||||
...axisThemeJson.grid.style
|
||||
}
|
||||
}
|
||||
},
|
||||
bar: {
|
||||
...barConfig
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,15 @@
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
<!-- 标签 -->
|
||||
<Label :optionData="optionData"></Label>
|
||||
<!-- 柱体 -->
|
||||
<Bar :optionData="optionData"></Bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { VChartGlobalSetting, Axis, Label, Bar } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
|
@ -25,7 +25,7 @@
|
||||
<n-input v-model:value="optionData.centerY" :step="1" :min="0" size="small"></n-input>
|
||||
</setting-item>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="标签">
|
||||
<SettingItemBox name="标签" v-if="optionData.label">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.label.visible" size="small"></n-switch>
|
||||
@ -45,11 +45,7 @@
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="分段样式">
|
||||
<setting-item name="纹理类型">
|
||||
<n-select
|
||||
v-model:value="optionData.pie.style.texture"
|
||||
:options="styleConfig.texture"
|
||||
size="small"
|
||||
></n-select>
|
||||
<n-select v-model:value="optionData.pie.style.texture" :options="styleConfig.texture" size="small"></n-select>
|
||||
</setting-item>
|
||||
<setting-item name="圆角大小">
|
||||
<n-input-number v-model:value="optionData.pie.style.cornerRadius" size="small" :min="0"></n-input-number>
|
||||
|
@ -74,5 +74,29 @@
|
||||
},
|
||||
"spaceRow": 10
|
||||
}
|
||||
},
|
||||
"label": {
|
||||
"visible": false,
|
||||
"position": "outside",
|
||||
"offset": 5,
|
||||
"type": "text",
|
||||
"style": {
|
||||
"fontSize": 12,
|
||||
"fill": "#B9B8CE",
|
||||
"fontFamily": "SimSun",
|
||||
"fontWeight": "normal",
|
||||
"angle": 0,
|
||||
"dx": 0,
|
||||
"dy": 0
|
||||
}
|
||||
},
|
||||
"bar": {
|
||||
"style": {
|
||||
"width": 10,
|
||||
"cornerRadius": 0,
|
||||
"fillOpacity": 1,
|
||||
"opacity": 1,
|
||||
"texture": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user