config.vue
3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<global-setting :optionData="optionData"></global-setting>
<collapse-item :name="t('information.wordCloud')" expanded>
<setting-item-box :name="t('common.shapeText')">
<setting-item>
<n-select v-model:value="optionData.series[0].shape" size="small" :options="ShapeEnumList" />
</setting-item>
<setting-item>
<n-checkbox v-model:checked="optionData.series[0].drawOutOfBound" size="small">{{
t('information.allowEdgeOut')
}}</n-checkbox>
</setting-item>
</setting-item-box>
<setting-item-box :name="t('common.layoutText')">
<setting-item :name="t('common.widthText')">
<n-slider
v-model:value="series.width"
:min="0"
:max="100"
:format-tooltip="sliderFormatTooltip"
@update:value="updateWidth"
></n-slider>
</setting-item>
<setting-item :name="t('common.heightText')">
<n-slider
v-model:value="series.height"
:min="0"
:max="100"
:format-tooltip="sliderFormatTooltip"
@update:value="updateHeight"
></n-slider>
</setting-item>
</setting-item-box>
<setting-item-box :name="t('common.styleText')" alone>
<setting-item :name="t('information.fontRange')">
<n-slider v-model:value="optionData.series[0].sizeRange" range :step="1" :min="6" :max="100" />
</setting-item>
<setting-item :name="t('information.rotaAngle')">
<n-slider v-model:value="series.rotationStep" :step="15" :min="0" :max="45" @update:value="updateRotation" />
</setting-item>
</setting-item-box>
</collapse-item>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
// import { option, ShapeEnumList } from './config'
import { option } from './config'
// eslint-disable-next-line no-unused-vars
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true
}
})
const t = window['$t']
const ShapeEnumList = [
{ label: t('common.symbolEnumList.circle'), value: 'circle' },
{ label: t('common.symbolEnumList.cardioid'), value: 'cardioid' },
{ label: t('common.symbolEnumList.diamond'), value: 'diamond' },
{ label: t('common.symbolEnumList.triangleForward'), value: 'triangle-forward' },
{ label: t('common.symbolEnumList.triangle'), value: 'triangle' },
{ label: t('common.symbolEnumList.pentagon'), value: 'pentagon' },
{ label: t('common.symbolEnumList.star'), value: 'star' }
]
const series = computed(() => {
const { width, height, rotationStep } = props.optionData.series[0]
return {
width: +width.replace('%', ''),
height: +height.replace('%', ''),
rotationStep
}
})
const sliderFormatTooltip = (v: number) => {
return `${v}%`
}
const updateWidth = (value: number) => {
props.optionData.series[0].width = `${value}%`
}
const updateHeight = (value: number) => {
props.optionData.series[0].height = `${value}%`
}
const updateRotation = (value: number) => {
props.optionData.series[0].rotationStep = value
props.optionData.series[0].rotationRange = value === 0 ? [0, 0] : [-90, 90]
}
</script>