图表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:或者任何演示请吗? –