我有一个大的分组图表,y轴将无法正确表示。我试图摆脱零,并仔细检查语法拼写错误,似乎无法搞清楚。基本上,y轴刻度是0 0 1 1,这就是它
<script>
window.onload = function ()
{
var data = [ ['18','47','11'] , ['10','4','1'] , ['0','0','1'] , ['0','2','0'] , ['8','9','0'] , ['6','6','0'] , ['5','3','1'] , ['2','7','0'] , ['9','5','1'] , ['5','6','0'] , ['6','5','0'] , ['4','5','0'] , ['3','2','2'] , ['3','2','0'] , ['0','1','0'] , ['1','0','0'] ] ;
var bar = new RGraph.Bar('cvs', data)
.Set('labels', ['JH', '166', 'JC', 'DR', 'KL', '206', '499', '181', '127', '01', '211', 'RK', '111', '46', '485', '65'])
.Set('colors', ['Gradient(#99f:#27afe9:#058DC7:#058DC7)', 'Gradient(#94f776:#50B332:#B1E59F)', 'Gradient(#fe783e:#EC561B:#F59F7D)'])
.Set('hmargin', 8)
.Set('strokestyle', 'white')
.Set('linewidth', 1)
.Set('shadow', true)
.Set('shadow.color', '#ccc')
.Set('shadow.offsetx', 0)
.Set('shadow.offsety', 0)
.Set('shadow.blur', 10)
.Draw();
}
</script>
答案 0 :(得分:2)
这是因为在数字周围加上单引号会将它们变成字符串 - 相当于0.所以你最终会绘制一个零数组。然后RGraph生成一个合适的比例,其中max为1 - 所以比例为0.2,0.4,0.6,0.8,1。然后默认情况下没有小数,所以它们被舍入 - 产生0,0,1,1,1。< / p>