Open wikiwikiki opened 10 months ago
` import { Bar } from '@ant-design/plots';
const Chart = ({ dataSource }) => { const config = { xField: 'value', yField: 'label', color: ({ label }: Record<string, any>) => { if (label === '收入') { return '#F34B45'; } if (label === '支出') { return '#2EA223'; } return '#5254CC'; }, title: { visible: true, text: '年度累计(万元)', }, tooltip: { title: '年度累计(万元)', showTitle: true, }, };
return ( <div style={{ width: '100%', height: '100%' }}> <Bar data={dataSource} {...config} /> </div> );
}; export default Chart; `
标题正常展示
给条形图配置title后,无法展示
图表配置
` import { Bar } from '@ant-design/plots';
const Chart = ({ dataSource }) => { const config = { xField: 'value', yField: 'label', color: ({ label }: Record<string, any>) => { if (label === '收入') { return '#F34B45'; } if (label === '支出') { return '#2EA223'; } return '#5254CC'; }, title: { visible: true, text: '年度累计(万元)', }, tooltip: { title: '年度累计(万元)', showTitle: true, }, };
}; export default Chart; `
展示截图
期望效果
标题正常展示