我正在使用float
图表。我遇到了multiplebar
图表问题。当我试图将 x 轴设为“ string
”时,它只显示单个条形。我需要在表单中显示 x 轴刻度,以便像城市名称一样刺痛。如何将 X 轴作为字符串获取多个条形?
my code:
$(function () {
var previousPoint;
var d1 = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ];
var d2 = [ ["January", 5], ["February", 2], ["March", 11], ["April", 2], ["May", 5], ["June", 12] ];
var d3 = [ ["January", 11], ["February", 12], ["March", 6], ["April",8], ["May", 11], ["June",16] ];
var ds = new Array();
ds.push({
data:d1,
bars: {
show: true,
barWidth: 0.2,
order: 1,
lineWidth : 2
}
});
ds.push({
data:d2,
bars: {
show: true,
barWidth: 0.2,
order: 2
}
});
ds.push({
data:d3,
bars: {
show: true,
barWidth: 0.2,
order: 3
}
});
//tooltip function
function showTooltip(x, y, contents, areAbsoluteXY) {
var rootElt = 'body';
$('<div id="tooltip" class="tooltip-with-bg">' + contents + '</div>').css( {
position: 'absolute',
display: 'none',
'z-index':'1010',
top: y,
left: x
}).prependTo(rootElt).show();
}
//Display graph
$.plot($("#placeholder"), ds, {
xaxis: { mode: "categories",
tickLength: 0
} ,
grid:{
hoverable:true
},
});
});