我的数据:
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,而不是我给出的字符串。 我做错了什么?
答案 0 :(得分: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);
charttype
将替换为实际类型(行/点..)
xaxis
不应位于series
对象内,而应位于同一级别。