我试图为不同的<VictoryPie />切片设置不同的颜色,这取决于data.x,但是我很难弄清楚.下面是代码:
style={{
data: {
stroke: (data) => {
switch (data.x) {
case 'one':
case 'two':
case 'three': return colors.aa;
case 'four':
case 'five':
case 'six':
case 'seven':
case 'eight':
case 'nine': return colors.bb;
default: return strokeColor;
}
},
},
}}colors.aa、colors.bb、strokeColor都是不同“#十六进制”的字符串变量。
没有控制台错误,也没有使用eslint语法错误,这使得我们很难知道出了什么问题.有人能帮忙吗?
发布于 2016-06-22 20:14:52
由于您基于“标签”(或字符串的值,请使用.xName):
style={{
data: {
stroke: (data) => {
switch (data.xName) {
case 'one':
case 'two':
case 'three': return colors.aa;
case 'four':
case 'five':
case 'six':
case 'seven':
case 'eight':
case 'nine': return colors.bb;
default: return strokeColor;
}
},
},
}}https://stackoverflow.com/questions/37976938
复制相似问题