0

嗨,我有一个用 g.raphael 制作的条形图

粗体括号中的 47 我希望在其中放置一个 if else 语句。如果我这样做似乎会导致错误。有什么帮助吗?

paper.barchart(-5, -20, 480, 260, [ (47) , 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52 , 52, 52], {颜色:["RGB(45,58,65)","RGB(217,31,53)","RGB(217,31,53)","RGB(217,31, 53)","RGB(217,31,53)","RGB(217,31,53)","RGB(205,148,43)","RGB(205,148,43)","RGB(205,148,43) )","RGB(205,148,43)","RGB(73,102,20)","RGB(73,102,20)","RGB(73,102,20)","RGB(73,102,20)","RGB (73,102,20)","RGB(0,99,186)","RGB(0,99,186)","RGB(0,99,186)","RGB(0,99,186)"]})

4

1 回答 1

1

我从未尝试过嵌套 if 块,但您可以在实例化之外定义数据数组,使用 if 语句根据您的条件构建它,然后在调用中使用您的数组变量:

var dataArray  = [...];
var colorArray = [...];
paper.barchart(-5, -20,
               480, 260,
               dataArray,
               {
                   colors : colorArray
               });
于 2013-04-06T12:48:19.143 回答