【发布时间】:2020-03-31 20:25:01
【问题描述】:
我正在尝试使用 ZingCharts 中的树模块控制图表中的工具提示文本和节点颜色。我想使用规则来更改给定值的节点颜色,并让工具提示显示该值。有没有可以为此工作的令牌? %node-value 不起作用。
window.addEventListener('load', () => {
let chartData = [
{
id: '111',
parent: '',
name: 'John Smith',
value: 'no problems'
},
{
id: '222',
parent: '111',
name: 'Jane Smith',
value: 'missing info'
},
{
id: '333',
parent: '111',
name: 'Jack Smith',
value: 'missing info'
},
];
let chartConfig = {
type: 'tree',
options: {
link: {
aspect: 'arc'
},
maxSize: 10,
minSize: 4,
node: {
type: 'circle',
borderWidth: 0,
rules : [
{
rule: '"%node-value" == "missing info"',
backgroundColor : 'red'
},
],
tooltip : {
fontSize : '20px',
text : '%node-value'
},
size : 10,
hoverState: {
borderAlpha: 1,
borderColor: '#000',
borderWidth: '2px'
},
label: {
width: '100px'
}
},
progression: 0,
textAttr: 'name',
valueAttr: 'value'
},
series: chartData
};
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
output: 'canvas'
});
});
在此处查看简化示例: https://app.zingsoft.com/demos/view/3C044JNF
【问题讨论】: