2011-09-01 94 views
0

我的数据:海军报条形图蜱不显示

var data5 = [ 
    { label: "my cat", data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'}, 
    { label: "my job", data: [[2,30], [5,20], [8,30]], color: '#42215F'} 
]; 

我的选择:

var type = {}; 
type[charttype] = {show: true}; 
type["xaxis"] = {ticks: [[1,"foo"], [2,"bar"], [4,"cat"], [5,"woo"], [7,"cookie"], [8,"yay"]]}; 

var chart_options = {}; 
chart_options["series"] = type; 

然而,当我

var plot = $.plot($(div), data5, chart_options); 

蜱虫只是显示为1-9,而不是用我给出的字符串。 我在做什么错?

回答

3

尝试这种情况:

var data5 = [ 
    { label: "my cat", data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'}, 
    { label: "my job", data: [[2,30], [5,20], [8,30]], color: '#42215F'} 
]; 

var chart_options = { 
    series: {lines:{show: true}}, 
    xaxis:{ticks: [[1,"foo"], [2,"bar"], [4,"cat"], [5,"woo"], [7,"cookie"], [8,"yay"] ]} 
}; 

var plot = $.plot($('div'), data5, chart_options); 

Demo

charttype被替换为实际类型(线/点..)

xaxis不应series物体的内部,而不是在相同的水平。

+0

这确实有效......所以我的格式必须有错误。我需要能够保持它的格式 - 你能看到错误是什么吗? – Colleen

+0

这里是你的版本(只是错误修复):http://jsfiddle.net/fSLth/,希望可以帮助 – stewe

+0

谢谢!我可以发誓xaxis是系列的一部分.... – Colleen