antvis/G2







The issue has been closed
树关系图给tooltip添加css样式无效 #6551
the-lemonboy posted onGitHub
问题描述
树关系图给tooltip添加css样式无效。
重现链接
No response
重现步骤
const chart = new Chart({
container: 'rightTwoChart',
height: chartHeight.value,
width: 400,
theme: 'classicDark',
});
chart
.treemap()
.data({
value: chartData.value,
})
.layout({
tile: 'treemapResquarify',
paddingInner: 5,
})
.encode('value', 'value')
.legend(false)
.tooltip({
title: (d) => d.data.name,
items: [
(d) => ({
name: '企业数量',
value: d.value,
channel: 'value',
}),
],
})
.style({
labelFill: '#1d1d1d',
labelLineWidth: 1.5,
labelFontSize: 10,
labelFontWeight: 'bold',
labelPosition: 'top-left',
labelDx: 5,
labelDy: 5,
});
chart
.interaction('tooltip', {
css: {
'.g2-tooltip': {
background: 'rgba(0, 0, 0, 0.50)',
'border-radius': ' 2px !important',
'box-shadow': '0px 10px 20px 0px rgba(0, 0, 0, 0.50) !important',
},
'.g2-tooltip-title': {
'border-bottom': '0.5px solid #0F445B',
color: '#fff',
},
'.g2-tooltip-list-item-name-label': {
color: '#fff',
'font-size': '10px',
},
'.g2-tooltip-list-item-value': {
color: '#fff',
'font-size': '10px',
},
},
})
.interaction({
treemapDrillDown: {
breadCrumbY: 12,
activeFill: '#ff0000',
breadCrumbFill: '#fff',
},
});
chart.render();
预期行为
期望样式是:
实际结果样式是:
平台
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
屏幕截图或视频(可选)
No response
补充说明(可选)
No response