Skip to content

Commit

Permalink
See DmitryBaranovskiy#137: Attempting to correct the rounding issue f…
Browse files Browse the repository at this point in the history
…or the chart size. Its better, but not perfect yet.
  • Loading branch information
bigspotteddog committed Jul 6, 2012
1 parent 1bc3d4c commit 0d3b665
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions g.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@
}
}

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 allx = Array.prototype.concat.apply([], valuesx);
var ally = Array.prototype.concat.apply([], valuesy);
var xdim = chartinst.snapEnds(Math.min.apply(Math, allx), Math.max.apply(Math, allx), valuesx[0].length - 1);
var minx = Math.min.apply(Math, allx);//xdim.from;
var maxx = Math.max.apply(Math, allx);//xdim.to;
var ydim = chartinst.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), valuesy[0].length - 1);
var miny = Math.min.apply(Math, ally);//ydim.from;
var maxy = Math.max.apply(Math, ally);//ydim.to;
var kx = (width - gutter * 2) / ((maxx - minx) || 1);
var ky = (height - gutter * 2) / ((maxy - miny) || 1);

var axis = paper.set();

Expand Down
2 changes: 1 addition & 1 deletion test/linechart.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
r.linechart(330, 10, 300, 220, x, [y.slice(0, 1e4), y2.slice(0, 1e4), y3.slice(0, 1e4)], { shade: true });
r.linechart(10, 250, 300, 220, x, [y, y2, y3], { nostroke: true, shade: true });

var lines = r.linechart(330, 250, 300, 220, [[1, 2, 3, 4, 5, 6, 7],[3.5, 4.5, 5.5, 6.5, 7, 8]], [[12, 32, 23, 15, 17, 27, 22], [10, 20, 30, 25, 15, 28]], { nostroke: false, axis: "0 0 1 1", symbol: "circle", smooth: true }).hoverColumn(function () {
var lines = r.linechart(330, 250, 300, 220, [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],[3.5, 4.5, 5.5, 6.5, 7, 8]], [[12, 32, 23, 15, 17, 27, 22, 28, 17, 29], [10, 20, 30, 25, 15, 28]], { nostroke: false, axis: "0 0 1 1", symbol: "circle", smooth: true }).hoverColumn(function () {
this.tags = r.set();

for (var i = 0, ii = this.y.length; i < ii; i++) {
Expand Down

0 comments on commit 0d3b665

Please sign in to comment.