圖表g.bar.js沒有繪製座標軸的選項。如果你看一下里面g.line.js,然而,是繪製軸的左右線98-117(目前)代碼塊:
var allx = Array.prototype.concat.apply([], valuesx),
ally = Array.prototype.concat.apply([], valuesy),
xdim = chartinst.snapEnds(Math.min.apply(Math, allx), Math.max.apply(Math, allx), valuesx[0].length - 1),
minx = xdim.from,
maxx = xdim.to,
ydim = chartinst.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), valuesy[0].length - 1),
miny = ydim.from,
maxy = ydim.to,
kx = (width - gutter * 2)/((maxx - minx) || 1),
ky = (height - gutter * 2)/((maxy - miny) || 1);
var axis = paper.set();
if (opts.axis) {
var ax = (opts.axis + "").split(/[,\s]+/);
+ax[0] && axis.push(chartinst.axis(x + gutter, y + gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter)/20), 2, paper));
+ax[1] && axis.push(chartinst.axis(x + width - gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter)/20), 3, paper));
+ax[2] && axis.push(chartinst.axis(x + gutter, y + height - gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter)/20), 0, paper));
+ax[3] && axis.push(chartinst.axis(x + gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter)/20), 1, paper));
}
這可以有效地在G是複製並粘貼到功能VBarchart .bar.js給你的軸選項。需要對x和y位置進行一些調整,並且maxy應該設置爲opts.total以獲得正確的縮放比例 - 是的,您需要放鬆一下,但它確實有效。
感謝提示stephband!一直困惑或缺乏信息,並轉而使用highcharts,而非常好! – jamen
@stephband:請您詳細說明一下這些小調整。我試圖將它複製到上述文件中。但不工作..你可以幫忙。謝謝 –
@stephband:或者任何演示請嗎? –