'use client'; import React, { useCallback } from 'react'; import { Select, Slider, InputNumber, Space, Typography, Radio } from 'antd'; import { useChartConfig } from '@/frameworks/hooks/useChartConfig'; const { Text } = Typography; const SHAPES = [ { label: '圆形', value: 'circle' }, { label: '心形', value: 'cardioid' }, { label: '菱形', value: 'diamond' }, { label: '三角形', value: 'triangle' }, { label: '五角星', value: 'star' }, { label: '五边形', value: 'pentagon' }, ]; const FONTS = [ { label: '默认 (sans-serif)', value: 'sans-serif' }, { label: '宋体', value: 'SimSun, serif' }, { label: '微软雅黑', value: 'Microsoft YaHei, sans-serif' }, { label: '等宽', value: 'monospace' }, { label: 'Impact', value: 'Impact, sans-serif' }, ]; const WEIGHTS = [ { label: '正常', value: 'normal' }, { label: '粗体', value: 'bold' }, { label: '更粗', value: '900' }, ]; export default function WordcloudConfig() { const { chart, setStyle } = useChartConfig(); const wc = (chart?.style as any)?.wordcloud ?? {}; const config = { shape: wc.shape ?? 'circle', sizeMin: wc.sizeMin ?? 14, sizeMax: wc.sizeMax ?? 80, rotationMin: wc.rotationMin ?? -45, rotationMax: wc.rotationMax ?? 45, rotationStep: wc.rotationStep ?? 15, gridSize: wc.gridSize ?? 8, fontFamily: wc.fontFamily ?? 'sans-serif', fontWeight: wc.fontWeight ?? 'bold', colorMode: wc.colorMode ?? 'palette', }; const update = useCallback( (partial: Record) => { setStyle({ wordcloud: { ...config, ...partial } } as any); }, [config, setStyle], ); if (chart?.type !== 'wordcloud') return null; return ( {/* Shape */}
形状 update({ fontFamily: val })} options={FONTS} size="small" style={{ width: '100%', marginTop: 4 }} />
{/* Font Weight */}
字重