我有一个饼图,其中包含两种类型的数据:ok和not ok。我想用绿色渲染确定,用红色渲染不好。我在文档中搜索过但没有结果。到目前为止,我的代码是:
new CanvasXpress("orderProgressCanvas", {
"y": {
"vars": [
"Ok",
"No"
],
"smps": [
"Percentuale completamento"
],
"colorRGB": [
"rgb(0,255,0)",
"rgb(255,0,0)"
],
"data": [
[
progress
],
[
100-progress
]
]
}
}, {
"graphType": "Pie",
"pieSegmentPrecision": 1,
"pieSegmentSeparation": 2,
"pieSegmentLabels": "outside",
"pieType": "solid",
"showLegend": false,
"background" : "rgb(192,208,216)"
});
但是颜色定义不起作用..任何想法? progress是一个从0到100的javascript变量。
由于
答案 0 :(得分:2)
我问主要开发者:
只需将您想要的颜色放在颜色属性中即可 组态。它们将按您指定的顺序选择。 另外,请确保指定足够的颜色,否则它们将是 在使用时回收利用。
'colors': ['rgb(234,234,1)', 'rgb(56,35,12)'.......etc]
我的代码已成为:
new CanvasXpress("orderProgressCanvas", {
"y": {
"vars": [
"Ok",
"No"
],
"smps": [
"Percentuale completamento"
],
"data": [
[
progress
],
[
100-progress
]
],
}
}, {
"graphType": "Pie",
"pieSegmentPrecision": 1,
"pieSegmentSeparation": 2,
"pieSegmentLabels": "outside",
"pieType": "solid",
"showLegend": false,
"background" : "rgb(192,208,216)",
"colors": [
"rgb(57,133,0)",
"rgb(163,0,8)"
],
});