config.vue 3.21 KB
<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>