Commit 073083f3d3724c1f68058db5c17a626d250486f8

Authored by xp.Huang
2 parents 68eb97ed 715b7a4b

Merge branch 'ft' into 'main'

feat(external/Componse): 组合新增标题

See merge request yunteng/thingskit-view!13
Showing 24 changed files with 468 additions and 358 deletions
... ... @@ -15,5 +15,5 @@ export const LeftCenterRightHeadConfig: ConfigType = {
15 15 categoryName: ChatCategoryEnumName.HEADCOMBINATION,
16 16 package: EPackagesCategoryEnum.COMPOSES,
17 17 chartFrame: ChartFrameEnum.COMMON,
18   - image: 'left_center_rightHead.png',
  18 + image: 'customHead1.png',
19 19 }
... ...
1 1 <template>
2 2 <div class="go-animat">
3 3 <div class="go-animat-item" :style="{ marginLeft: animat.x + 'px', marginTop: animat.y + 'px' }">
4   - <svg :width="animat.w + 'px'" :height="animat.h + 'px'">
  4 + <svg :width="w" :height="h">
5 5 <polyline
6 6 fill="transparent"
7 7 stroke-width="3"
8   - :points="`0,20 ${animat.w / 5.555555555555556},20 ${animat.w / 5},40 ${animat.w / 4},40 ${
9   - animat.w / 3.703703703703704
10   - },60 ${animat.w / 1.388888888888889},60 ${animat.w / 1.333333333333333},40 ${animat.w / 1.25},40 ${
11   - animat.w / 1.219512195121951
12   - },20 ${animat.w},20`"
  8 + :points="`0,20 ${w / 5.555555555555556},20 ${w / 5},40 ${w / 4},40 ${
  9 + w / 3.703703703703704
  10 + },60 ${w / 1.388888888888889},60 ${w / 1.333333333333333},40 ${w / 1.25},40 ${
  11 + w / 1.219512195121951
  12 + },20 ${w},20`"
13 13 :stroke="animat.colors[0]"
14 14 >
15 15 <animate
... ... @@ -28,7 +28,7 @@
28 28 <polyline
29 29 fill="transparent"
30 30 stroke-width="2"
31   - :points="`${animat.w / 3.333333333333333},80 ${animat.w / 1.428571428571429},80`"
  31 + :points="`${w / 3.333333333333333},80 ${w / 1.428571428571429},80`"
32 32 :stroke="animat.colors[1]"
33 33 >
34 34 <animate
... ... @@ -70,6 +70,8 @@ props.chartConfig.attr.h = 300
70 70 props.chartConfig.attr.x = 0
71 71 props.chartConfig.attr.y = 0
72 72
  73 +const { w, h } = toRefs(props.chartConfig.attr)
  74 +
73 75 const { animat } = toRefs(props.chartConfig.option)
74 76 </script>
75 77
... ...
... ... @@ -13,5 +13,5 @@ export const LeftCenterRightHeadCommonConfig: ConfigType = {
13 13 categoryName: ChatCategoryEnumName.HEADCOMBINATION,
14 14 package: EPackagesCategoryEnum.COMPOSES,
15 15 chartFrame: ChartFrameEnum.COMMON,
16   - image: 'left_center_rightHead.png',
  16 + image: 'customHead2.png',
17 17 }
... ...
  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { ButtonConfig } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + dataset: '默认',
  8 + /**
  9 + * Naive UI button部分属性
  10 + */
  11 + attribute:{
  12 + //尺寸
  13 + size:'medium',
  14 + //透明
  15 + ghost:false,
  16 + //加载
  17 + loading:false,
  18 + //自定义颜色
  19 + color:'#ffffff',
  20 + //文字背景
  21 + textColor:'black'
  22 + }
  23 +}
  24 +
  25 +export default class Config extends PublicConfigClass implements CreateComponentType {
  26 + public key = ButtonConfig.key
  27 + public chartConfig = cloneDeep(ButtonConfig)
  28 + public option = cloneDeep(option)
  29 +}
... ...
  1 +<template>
  2 + <CollapseItem name="按钮配置" :expanded="true">
  3 + <SettingItemBox name="信息">
  4 + <SettingItem name="文字">
  5 + <n-input size="small" v-model:value="optionData.dataset"></n-input>
  6 + </SettingItem>
  7 + <SettingItem name="文字颜色">
  8 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.textColor"></n-color-picker>
  9 + </SettingItem>
  10 + <SettingItem>
  11 + <n-button size="small" @click="optionData.attribute.textColor ='black'"> 恢复默认 </n-button>
  12 + </SettingItem>
  13 + </SettingItemBox>
  14 + <SettingItemBox name="属性">
  15 + <SettingItem name="颜色">
  16 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.color"></n-color-picker>
  17 + </SettingItem>
  18 + <SettingItem>
  19 + <n-button size="small" @click="optionData.attribute.color ='#ffffff'"> 恢复默认 </n-button>
  20 + </SettingItem>
  21 + <SettingItem name="是否透明">
  22 + <n-switch v-model:value="optionData.attribute.ghost" />
  23 + </SettingItem>
  24 + <SettingItem name="是否加载">
  25 + <n-switch v-model:value="optionData.attribute.loading" />
  26 + </SettingItem>
  27 + </SettingItemBox>
  28 + </CollapseItem>
  29 +</template>
  30 +
  31 +<script setup lang="ts">
  32 +import { PropType } from 'vue'
  33 +import { option } from './config'
  34 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  35 +
  36 +defineProps({
  37 + optionData: {
  38 + type: Object as PropType<typeof option>,
  39 + required: true
  40 + }
  41 +})
  42 +</script>
... ...
src/packages/components/external/Composes/Mores/Button/index.ts renamed from src/packages/components/external/Composes/Mores/WordCloud/index.ts
1   -import { useWidgetKey } from '@/packages/external/useWidgetKey'
2   -import { ConfigType, ChartFrameEnum } from '@/packages/index.d'
3   -import { EPackagesCategoryEnum } from '../../../types'
  1 +import { ChartFrameEnum, ConfigType } from '@/packages/index.d'
  2 +import { EPackagesCategoryEnum } from '@/packages/components/external/types'
4 3 import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
  4 +import { useWidgetKey } from '@/packages/external/useWidgetKey'
5 5
6   -const { key, conKey, chartKey } = useWidgetKey('WordCloud')
7   -export const WordCloudConfig: ConfigType = {
8   - key,
9   - chartKey,
10   - conKey,
11   - title: '词云',
12   - category: ChatCategoryEnum.MORE,
13   - categoryName: ChatCategoryEnumName.MORE,
14   - package: EPackagesCategoryEnum.COMPOSES,
15   - chartFrame: ChartFrameEnum.COMMON,
16   - image: 'words_cloud.png'
  6 +const { key, chartKey, conKey } = useWidgetKey('Button')
  7 +export const ButtonConfig: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '按钮',
  12 + category: ChatCategoryEnum.MORE,
  13 + categoryName: ChatCategoryEnumName.MORE,
  14 + package: EPackagesCategoryEnum.COMPOSES,
  15 + chartFrame: ChartFrameEnum.NAIVE_UI,
  16 + image: 'button.png',
17 17 }
... ...
  1 +<template>
  2 + <div class="go-content-box">
  3 + <n-button class="content" @click="handleClick" v-bind={...attribute}>{{dataset}}</n-button>
  4 + </div>
  5 +</template>
  6 +<script setup lang="ts">
  7 +import { PropType, toRefs } from 'vue'
  8 +import { CreateComponentType } from '@/packages/index.d'
  9 +import {option as configOption} from './config'
  10 +
  11 +
  12 +const props = defineProps({
  13 + chartConfig: {
  14 + type: Object as PropType<CreateComponentType>,
  15 + required: true
  16 + }
  17 +})
  18 +
  19 +//修改默认宽高距离位置
  20 +props.chartConfig.attr.w = 100
  21 +props.chartConfig.attr.h = 50
  22 +props.chartConfig.attr.x = 200
  23 +props.chartConfig.attr.y = 200
  24 +
  25 +const { dataset,attribute }= toRefs(props.chartConfig.option) as unknown as typeof configOption
  26 +
  27 +const { w, h } = toRefs(props.chartConfig.attr)
  28 +
  29 +const handleClick=()=>{
  30 + attribute.loading=true
  31 + window['$message'].success('您点击了按钮')
  32 + attribute.loading=false
  33 +}
  34 +
  35 +
  36 +
  37 +</script>
  38 +
  39 +<style lang="scss" scoped>
  40 +.go-content-box{
  41 + display: flex;
  42 + align-items: center;
  43 + justify-content: center;
  44 + .content{
  45 + width:v-bind('w + "px"');
  46 + height:v-bind('h + "px"');
  47 + }
  48 +}
  49 +</style>
... ...
  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { DateTimeConfig } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + /**
  8 + * Naive UI Date Picker部分属性
  9 + */
  10 + dataset:[Date.now(), Date.now()],
  11 + attribute:{
  12 + //是否支持清除
  13 + clearable:false,
  14 + //是否禁用
  15 + disabled:false,
  16 + //尺寸
  17 + size:'medium'
  18 + }
  19 +}
  20 +
  21 +export default class Config extends PublicConfigClass implements CreateComponentType {
  22 + public key = DateTimeConfig.key
  23 + public chartConfig = cloneDeep(DateTimeConfig)
  24 + public option = cloneDeep(option)
  25 +}
... ...
  1 +<template>
  2 + <CollapseItem name="日期时间配置" :expanded="true">
  3 + <SettingItemBox name="属性">
  4 + <SettingItem name="是否支持清除">
  5 + <n-switch v-model:value="optionData.attribute.clearable" />
  6 + </SettingItem>
  7 + <SettingItem name="是否禁用">
  8 + <n-switch v-model:value="optionData.attribute.disabled" />
  9 + </SettingItem>
  10 + <SettingItem name="尺寸">
  11 + <n-select v-model:value="optionData.attribute.size" :options="options" />
  12 + </SettingItem>
  13 + </SettingItemBox>
  14 + </CollapseItem>
  15 +</template>
  16 +
  17 +<script setup lang="ts">
  18 +import { PropType } from 'vue'
  19 +import { option } from './config'
  20 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  21 +
  22 +defineProps({
  23 + optionData: {
  24 + type: Object as PropType<typeof option>,
  25 + required: true
  26 + }
  27 +})
  28 +
  29 +const options=[
  30 + {
  31 + label: "小型",
  32 + value: 'small',
  33 + },
  34 + {
  35 + label: '中等',
  36 + value: 'medium'
  37 + },
  38 + {
  39 + label: '大型',
  40 + value: 'large'
  41 + },
  42 +]
  43 +</script>
... ...
  1 +import { ChartFrameEnum, ConfigType } from '@/packages/index.d'
  2 +import { EPackagesCategoryEnum } from '@/packages/components/external/types'
  3 +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
  4 +import { useWidgetKey } from '@/packages/external/useWidgetKey'
  5 +
  6 +const { key, chartKey, conKey } = useWidgetKey('DateTime')
  7 +export const DateTimeConfig: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '日期时间',
  12 + category: ChatCategoryEnum.MORE,
  13 + categoryName: ChatCategoryEnumName.MORE,
  14 + package: EPackagesCategoryEnum.COMPOSES,
  15 + chartFrame: ChartFrameEnum.NAIVE_UI,
  16 + image: 'dateTime.png',
  17 +}
... ...
  1 +<template>
  2 + <div class="go-content-box" >
  3 + <n-date-picker class="content" @confirm="handleOnConfirm" v-bind={...attribute} v-model:value="dataset" type="datetimerange" />
  4 + </div>
  5 +</template>
  6 +<script setup lang="ts">
  7 +import { PropType, toRefs } from 'vue'
  8 +import { CreateComponentType } from '@/packages/index.d'
  9 +
  10 +const props = defineProps({
  11 + chartConfig: {
  12 + type: Object as PropType<CreateComponentType>,
  13 + required: true
  14 + }
  15 +})
  16 +
  17 +//修改默认宽高距离位置
  18 +props.chartConfig.attr.w = 600
  19 +props.chartConfig.attr.h = 100
  20 +props.chartConfig.attr.x = 200
  21 +props.chartConfig.attr.y = 200
  22 +
  23 +const { dataset,attribute }= toRefs(props.chartConfig.option)
  24 +
  25 +const { w, h } = toRefs(props.chartConfig.attr)
  26 +
  27 +const handleOnConfirm=(values:[number, number])=>{
  28 + window['$message'].success(`您选中了时间段[${values}]`)
  29 +}
  30 +
  31 +
  32 +
  33 +</script>
  34 +
  35 +<style lang="scss" scoped>
  36 +.go-content-box {
  37 + display: flex;
  38 + align-items: center;
  39 + justify-content: center;
  40 + .content{
  41 + width:v-bind('w + "px"');
  42 + height:v-bind('h + "px"');
  43 + }
  44 +}
  45 +</style>
... ...
  1 +import { PublicConfigClass } from '@/packages/public'
  2 +import { CreateComponentType } from '@/packages/index.d'
  3 +import { TitleConfig } from './index'
  4 +import cloneDeep from 'lodash/cloneDeep'
  5 +
  6 +export const option = {
  7 + dataset:'我是标题',
  8 + attribute:{
  9 + titleColor:'#fff',
  10 + titleSize:'16',
  11 + svg_7:'blue',
  12 + svg_8:'red',
  13 + svg_16:'red',
  14 + svg_14:'red',
  15 + svg_21:'red',
  16 + svg_7_opacity:1,
  17 + svg_8_opacity:1,
  18 + svg_16_opacity:1,
  19 + svg_14_opacity:1,
  20 + linearGradient:{
  21 + stop_color1:'#447799',
  22 + stop_color2:'#224488',
  23 + svg_21_opacity1:1,
  24 + svg_21_opacity2:1,
  25 + }
  26 + }
  27 +}
  28 +
  29 +export default class Config extends PublicConfigClass implements CreateComponentType {
  30 + public key = TitleConfig.key
  31 + public chartConfig = cloneDeep(TitleConfig)
  32 + public option = cloneDeep(option)
  33 +}
... ...
  1 +<template>
  2 + <CollapseItem name="配置" :expanded="true">
  3 + <SettingItemBox name="文字">
  4 + <SettingItem name="内容">
  5 + <n-input size="small" v-model:value="optionData.dataset"></n-input>
  6 + </SettingItem>
  7 + <SettingItem name="颜色">
  8 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.titleColor"></n-color-picker>
  9 + </SettingItem>
  10 + <SettingItem>
  11 + <n-button size="small" @click="optionData.attribute.titleColor ='#fff'"> 恢复默认 </n-button>
  12 + </SettingItem>
  13 + <SettingItem name="大小">
  14 + <n-input-number v-model:value="optionData.attribute.titleSize" size="small" placeholder="大小"></n-input-number>
  15 + </SettingItem>
  16 + </SettingItemBox>
  17 + <SettingItemBox name="左边装饰">
  18 + <SettingItem name="颜色">
  19 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_16"></n-color-picker>
  20 + </SettingItem>
  21 + <SettingItem name="透明度">
  22 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_16_opacity" size="small" placeholder="透明度1"></n-input-number>
  23 + </SettingItem>
  24 + </SettingItemBox>
  25 + <SettingItemBox name="三角装饰">
  26 + <SettingItem name="颜色">
  27 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_14"></n-color-picker>
  28 + </SettingItem>
  29 + <SettingItem name="透明度">
  30 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_14_opacity" size="small" placeholder="透明度1"></n-input-number>
  31 + </SettingItem>
  32 + </SettingItemBox>
  33 + <SettingItemBox name="右边装饰">
  34 + <SettingItem name="颜色1">
  35 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_7"></n-color-picker>
  36 + </SettingItem>
  37 + <SettingItem name="颜色2">
  38 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.svg_8"></n-color-picker>
  39 + </SettingItem>
  40 + <SettingItem name="透明度1">
  41 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_7_opacity" size="small" placeholder="透明度1"></n-input-number>
  42 + </SettingItem>
  43 + <SettingItem name="透明度2">
  44 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.svg_8_opacity" size="small" placeholder="透明度2"></n-input-number>
  45 + </SettingItem>
  46 + </SettingItemBox>
  47 + <SettingItemBox name="装饰渐变">
  48 + <SettingItem name="渐变颜色1">
  49 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.linearGradient.stop_color1"></n-color-picker>
  50 + </SettingItem>
  51 + <SettingItem name="渐变颜色2">
  52 + <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.attribute.linearGradient.stop_color2"></n-color-picker>
  53 + </SettingItem>
  54 + <SettingItem name="透明度1">
  55 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.linearGradient.svg_21_opacity1" size="small" placeholder="透明度1"></n-input-number>
  56 + </SettingItem>
  57 + <SettingItem name="透明度2">
  58 + <n-input-number :min="0" :max="1" v-model:value="optionData.attribute.linearGradient.svg_21_opacity2" size="small" placeholder="透明度1"></n-input-number>
  59 + </SettingItem>
  60 + </SettingItemBox>
  61 + </CollapseItem>
  62 +</template>
  63 +
  64 +<script setup lang="ts">
  65 +import { PropType } from 'vue'
  66 +import { option } from './config'
  67 +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  68 +
  69 +defineProps({
  70 + optionData: {
  71 + type: Object as PropType<typeof option>,
  72 + required: true
  73 + }
  74 +})
  75 +</script>
... ...
  1 +import { ChartFrameEnum, ConfigType } from '@/packages/index.d'
  2 +import { EPackagesCategoryEnum } from '@/packages/components/external/types'
  3 +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
  4 +import { useWidgetKey } from '@/packages/external/useWidgetKey'
  5 +
  6 +const { key, chartKey, conKey } = useWidgetKey('Title')
  7 +export const TitleConfig: ConfigType = {
  8 + key,
  9 + chartKey,
  10 + conKey,
  11 + title: '标题',
  12 + category: ChatCategoryEnum.MORE,
  13 + categoryName: ChatCategoryEnumName.MORE,
  14 + package: EPackagesCategoryEnum.COMPOSES,
  15 + chartFrame: ChartFrameEnum.NAIVE_UI,
  16 + image: 'dateTime.png',
  17 +}
... ...
  1 +<template>
  2 + <div class="go-content-box" >
  3 +<svg xmlns="http://www.w3.org/2000/svg" width="782" height="600">
  4 + <defs>
  5 + <defs>
  6 + <linearGradient id="my-cool-gradient" x1="0%" y1="0%" x2="100%" y2="0%">
  7 + <stop offset="0%" :style="{stopColor:attribute.linearGradient.stop_color1,stopOpacity:attribute.linearGradient.svg_21_opacity1 }"/>
  8 + <stop offset="100%" :style="{stopColor:attribute.linearGradient.stop_color2,stopOpacity:attribute.linearGradient.svg_21_opacity2}"/>
  9 + </linearGradient>
  10 + </defs>
  11 + </defs>
  12 + <g>
  13 + <rect stroke="#000" id="svg_6" height="0" width="2" y="189.5" x="523" fill="#fff"/>
  14 + <path :opacity="attribute.svg_7_opacity" transform="rotate(-137 422.766 284.992)" stroke="#000" id="svg_7" d="m412.87465,287.39672l3.95636,-4.80932l15.82545,0l-3.95636,4.80932l-15.82545,0z" :fill="attribute.svg_7"/>
  15 + <path :opacity="attribute.svg_8_opacity" transform="rotate(44 444.883 283.871)" stroke="#000" id="svg_8" d="m435.52609,286.39738l3.74294,-5.0534l14.97175,0l-3.74294,5.0534l-14.97175,0z" :fill="attribute.svg_8"/>
  16 + <rect id="svg_10" height="0" width="1" y="242.5" x="235" stroke="#000" fill="#fff"/>
  17 + <text xml:space="preserve" text-anchor="start" font-family="Noto Sans JP" :font-size="attribute.titleSize" stroke-width="0" id="svg_12" y="290.5" x="214" stroke="#000" :fill="attribute.titleColor">{{ dataset }}</text>
  18 + <path :opacity="attribute.svg_14_opacity" transform="rotate(90 198.922 284.168)" stroke="#000" id="svg_14" d="m193.42189,288.16843l5.50043,-8.00001l5.50043,8.00001l-11.00085,0z" stroke-width="0" :fill="attribute.svg_14"/>
  19 + <path id="svg_15" d="m259.7,311.34437l0.5,-1.00001l0.5,1.00001l-1.00001,0z" stroke-width="0" stroke="#000" fill="#000000"/>
  20 + <rect stroke="#000" id="svg_16" height="33" width="4" y="269" x="181" :fill="attribute.svg_16" :opacity="attribute.svg_16_opacity"/>
  21 + <rect id="svg_17" height="0" width="2" y="368.5" x="187" stroke="#000" fill="#6D97AB"/>
  22 + <rect id="svg_18" height="13" width="0" y="290.5" x="167" stroke="#000" fill="#6D97AB"/>
  23 + <rect id="svg_20" height="0" width="1" y="193.5" x="281" stroke="#000" fill="#6D97AB"/>
  24 + <path stroke="#000" id="svg_21" d="m184,269l299.00001,0l0,33l-299.00001,0l0,-33z" opacity="0.35" fill="url(#my-cool-gradient)"/>
  25 + </g>
  26 +
  27 +</svg>
  28 + </div>
  29 +</template>
  30 +<script setup lang="ts">
  31 +import { PropType, toRefs } from 'vue'
  32 +import { CreateComponentType } from '@/packages/index.d'
  33 +
  34 +const props = defineProps({
  35 + chartConfig: {
  36 + type: Object as PropType<CreateComponentType>,
  37 + required: true
  38 + }
  39 +})
  40 +
  41 +//修改默认宽高距离位置
  42 +props.chartConfig.attr.w = 600
  43 +props.chartConfig.attr.h = 100
  44 +props.chartConfig.attr.x = 200
  45 +props.chartConfig.attr.y = 200
  46 +
  47 +const { dataset,attribute }= toRefs(props.chartConfig.option)
  48 +
  49 +const { w, h } = toRefs(props.chartConfig.attr)
  50 +
  51 +
  52 +</script>
  53 +
  54 +<style lang="scss" scoped>
  55 +.go-content-box {
  56 + display: flex;
  57 + align-items: center;
  58 + justify-content: center;
  59 + .content{
  60 + width:v-bind('w + "px"');
  61 + height:v-bind('h + "px"');
  62 + }
  63 +}
  64 +</style>
... ...
1   -import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
2   -import { WordCloudConfig } from './index'
3   -import { CreateComponentType } from '@/packages/index.d'
4   -import cloneDeep from 'lodash/cloneDeep'
5   -import dataJson from './data.json'
6   -
7   -export const includes = []
8   -
9   -export const ShapeEnumList = [
10   - { label: '圆形', value: 'circle' },
11   - { label: '心形', value: 'cardioid' },
12   - { label: '钻石', value: 'diamond' },
13   - { label: '右三角形', value: 'triangle-forward' },
14   - { label: '三角形', value: 'triangle' },
15   - { label: '五边形', value: 'pentagon' },
16   - { label: '星星', value: 'star' }
17   -]
18   -
19   -export const option = {
20   - dataset: [...dataJson],
21   - tooltip: {},
22   - series: [
23   - {
24   - type: 'wordCloud',
25   -
26   - // “云”绘制的形状,可以是表示为回调函数,也可以是固定关键字。
27   - // 可用值有:circle|cardioid|diamond|triangle-forward|triangle|pentagon|star
28   - shape: 'circle',
29   -
30   - // 白色区域将被排除在绘制文本之外的剪影图像。
31   - // 随着云的形状生长,形状选项将继续应用。
32   - // maskImage: maskImage,
33   -
34   - // Folllowing left/top/width/height/right/bottom are used for positioning the word cloud
35   - // Default to be put in the center and has 75% x 80% size.
36   - left: 'center',
37   - top: 'center',
38   - width: '70%',
39   - height: '80%',
40   - right: null,
41   - bottom: null,
42   -
43   - // 文本大小范围,默认 [12,60]
44   - sizeRange: [12, 60],
45   -
46   - // 文本旋转范围和程度的步骤。 文本将通过旋转步骤45在[-90,90]中随机旋转
47   - rotationRange: [0, 0],
48   - rotationStep: 0,
49   -
50   - // size of the grid in pixels for marking the availability of the canvas
51   - // 网格大小越大,单词之间的差距就越大。
52   - gridSize: 8,
53   -
54   - // 设置为true,以允许单词在画布之外部分地绘制。允许绘制大于画布的大小
55   - drawOutOfBound: false,
56   -
57   - // If perform layout animation.
58   - // NOTE disable it will lead to UI blocking when there is lots of words.
59   - layoutAnimation: true,
60   -
61   - // Global text style
62   - textStyle: {
63   - fontFamily: 'sans-serif',
64   - fontWeight: 'bold'
65   - // 颜色可以是回调功能或颜色字符串
66   - // color: function () {
67   - // // 随机颜色
68   - // return (
69   - // 'rgb(' +
70   - // [Math.round(Math.random() * 160), Math.round(Math.random() * 160), Math.round(Math.random() * 160)].join(
71   - // ','
72   - // ) +
73   - // ')'
74   - // )
75   - // }
76   - },
77   - emphasis: {
78   - focus: 'self',
79   -
80   - textStyle: {
81   - shadowBlur: 10,
82   - shadowColor: '#333'
83   - }
84   - },
85   - data: [...dataJson]
86   - }
87   - ]
88   -}
89   -
90   -export default class Config extends PublicConfigClass implements CreateComponentType {
91   - public key = WordCloudConfig.key
92   - public chartConfig = cloneDeep(WordCloudConfig)
93   - // 图表配置项
94   - public option = echartOptionProfixHandle(option, includes)
95   -}
1   -<template>
2   - <collapse-item name="词云" expanded>
3   - <setting-item-box name="形状">
4   - <setting-item>
5   - <n-select v-model:value="optionData.series[0].shape" size="small" :options="ShapeEnumList" />
6   - </setting-item>
7   - <setting-item>
8   - <n-checkbox v-model:checked="optionData.series[0].drawOutOfBound" size="small">允许出边</n-checkbox>
9   - </setting-item>
10   - </setting-item-box>
11   -
12   - <setting-item-box name="布局">
13   - <setting-item name="宽度">
14   - <n-slider
15   - v-model:value="series.width"
16   - :min="0"
17   - :max="100"
18   - :format-tooltip="sliderFormatTooltip"
19   - @update:value="updateWidth"
20   - ></n-slider>
21   - </setting-item>
22   - <setting-item name="高度">
23   - <n-slider
24   - v-model:value="series.height"
25   - :min="0"
26   - :max="100"
27   - :format-tooltip="sliderFormatTooltip"
28   - @update:value="updateHeight"
29   - ></n-slider>
30   - </setting-item>
31   - </setting-item-box>
32   -
33   - <setting-item-box name="样式" alone>
34   - <setting-item name="字体区间(最小/最大字体)">
35   - <n-slider v-model:value="optionData.series[0].sizeRange" range :step="1" :min="6" :max="100" />
36   - </setting-item>
37   - <setting-item name="旋转角度">
38   - <n-slider v-model:value="series.rotationStep" :step="15" :min="0" :max="45" @update:value="updateRotation" />
39   - </setting-item>
40   - </setting-item-box>
41   - </collapse-item>
42   -</template>
43   -
44   -<script setup lang="ts">
45   -import { PropType, computed } from 'vue'
46   -import { option, ShapeEnumList } from './config'
47   -// eslint-disable-next-line no-unused-vars
48   -import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
49   -
50   -const props = defineProps({
51   - optionData: {
52   - type: Object as PropType<typeof option>,
53   - required: true
54   - }
55   -})
56   -
57   -const series = computed(() => {
58   - const { width, height, rotationStep } = props.optionData.series[0]
59   - return {
60   - width: +width.replace('%', ''),
61   - height: +height.replace('%', ''),
62   - rotationStep
63   - }
64   -})
65   -
66   -const sliderFormatTooltip = (v: number) => {
67   - return `${v}%`
68   -}
69   -
70   -const updateWidth = (value: number) => {
71   - props.optionData.series[0].width = `${value}%`
72   -}
73   -
74   -const updateHeight = (value: number) => {
75   - props.optionData.series[0].height = `${value}%`
76   -}
77   -
78   -const updateRotation = (value: number) => {
79   - props.optionData.series[0].rotationStep = value
80   - props.optionData.series[0].rotationRange = value === 0 ? [0, 0] : [-90, 90]
81   -}
82   -</script>
1   -[
2   - {
3   - "name": "数据可视化",
4   - "value": 8000,
5   - "textStyle": {
6   - "color": "#78fbb2"
7   - },
8   - "emphasis": {
9   - "textStyle": {
10   - "color": "red"
11   - }
12   - }
13   - },
14   - {
15   - "name": "GO VIEW",
16   - "value": 6181
17   - },
18   - {
19   - "name": "低代码",
20   - "value": 4386
21   - },
22   - {
23   - "name": "Vue3",
24   - "value": 4055
25   - },
26   - {
27   - "name": "TypeScript4",
28   - "value": 2467
29   - },
30   - {
31   - "name": "Vite2",
32   - "value": 2244
33   - },
34   - {
35   - "name": "NaiveUI",
36   - "value": 1898
37   - },
38   - {
39   - "name": "ECharts5",
40   - "value": 1484
41   - },
42   - {
43   - "name": "Axios",
44   - "value": 1112
45   - },
46   - {
47   - "name": "Pinia2",
48   - "value": 965
49   - },
50   - {
51   - "name": "PlopJS",
52   - "value": 847
53   - },
54   - {
55   - "name": "sfc",
56   - "value": 582
57   - },
58   - {
59   - "name": "SCSS",
60   - "value": 555
61   - },
62   - {
63   - "name": "pnpm",
64   - "value": 550
65   - },
66   - {
67   - "name": "eslint",
68   - "value": 462
69   - },
70   - {
71   - "name": "json",
72   - "value": 366
73   - },
74   - {
75   - "name": "图表",
76   - "value": 360
77   - },
78   - {
79   - "name": "地图",
80   - "value": 282
81   - },
82   - {
83   - "name": "时钟",
84   - "value": 273
85   - },
86   - {
87   - "name": "标题",
88   - "value": 265
89   - }
90   -]
1   -<template>
2   - <v-chart ref="vChartRef" :theme="themeColor" :option="option" :manual-update="isPreview()"
3   - :update-options="{ replaceMerge: replaceMergeArr }" autoresize></v-chart>
4   -</template>
5   -
6   -<script setup lang="ts">
7   -import { ref, computed, watch, PropType } from 'vue'
8   -import VChart from 'vue-echarts'
9   -import 'echarts-wordcloud'
10   -import { use } from 'echarts/core'
11   -import { CanvasRenderer } from 'echarts/renderers'
12   -import config, { includes } from './config'
13   -import { mergeTheme, setOption } from '@/packages/public/chart'
14   -import { useChartDataFetch } from '@/hooks'
15   -import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
16   -import { isPreview } from '@/utils'
17   -import { GridComponent, TooltipComponent } from 'echarts/components'
18   -import dataJson from './data.json'
19   -
20   -const props = defineProps({
21   - themeSetting: {
22   - type: Object,
23   - required: true
24   - },
25   - themeColor: {
26   - type: Object,
27   - required: true
28   - },
29   - chartConfig: {
30   - type: Object as PropType<config>,
31   - required: true
32   - }
33   -})
34   -
35   -use([CanvasRenderer, GridComponent, TooltipComponent])
36   -
37   -const replaceMergeArr = ref<string[]>()
38   -
39   -const option = computed(() => {
40   - return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
41   -})
42   -
43   -const dataSetHandle = (dataset: typeof dataJson) => {
44   - try {
45   - dataset && (props.chartConfig.option.series[0].data = dataset)
46   - vChartRef.value && isPreview() && setOption(vChartRef.value, props.chartConfig.option)
47   - } catch (error) {
48   - console.log(error)
49   - }
50   -}
51   -
52   -// dataset 无法变更条数的补丁
53   -watch(
54   - () => props.chartConfig.option.dataset,
55   - newData => {
56   - dataSetHandle(newData)
57   - },
58   - {
59   - deep: false
60   - }
61   -)
62   -
63   -const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: typeof dataJson) => {
64   - dataSetHandle(newData)
65   -})
66   -</script>
1   -import { WordCloudConfig } from './WordCloud/index'
  1 +import { ButtonConfig } from './Button/index'
  2 +import { DateTimeConfig } from './DateTime/index'
  3 +import { TitleConfig } from './Title/index'
2 4
3   -export default [WordCloudConfig]
  5 +export default [ButtonConfig,DateTimeConfig,TitleConfig]
... ...