antvis/G2


The issue has been closed
标题(Title)设置不生效。 #6117
d18zj posted onGitHub
问题描述
无论是采用下面的简单代码 还是sandbox代码: https://codesandbox.io/p/sandbox/test-title-djx8rn 设置的Title都无法显示。
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@antv/g2/dist/g2.min.js"></script>
</head>
<body>
<div id="container" />
<script>
const data = [
{ genre: 'Sports11', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
];
// 初始化图表实例
const chart = new G2.Chart({
container: 'container',
autoFit: true,
});
// 声明可视化
chart
.interval() // 创建一个 Interval 标记
.data(data) // 绑定数据
.title({ title: 'Test' })
.encode('x', 'genre') // 编码 x 通道
.encode('y', 'sold'); // 编码 y 通道
// 渲染可视化
chart.render();
</script>
</body>
</html>
重现链接
https://codesandbox.io/p/sandbox/test-title-djx8rn
平台
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
屏幕截图或视频(可选)
补充说明(可选)
版本:5.1.14
但我在官网示例:https://g2.antv.antgroup.com/examples/general/interval/#bar-basic-stacked 中测试title是生效的。