Permalink
Browse files

Some rendering tweaks

  • Loading branch information...
1 parent 80bfa10 commit c58807c70000d964bd3b44917d5578bda3f24c06 Martin Kleppmann committed Apr 13, 2009
Showing with 5 additions and 16 deletions.
  1. +4 −7 PlotKit/Canvas.js
  2. +1 −9 PlotKit/Layout.js
View
@@ -259,16 +259,13 @@ PlotKit.CanvasRenderer.prototype._renderLineChart = function() {
this.area.h * point.y + this.area.y);
};
MochiKit.Iter.forEach(this.layout.points, partial(addPoint, ctx), this);
- if (this.options.shouldFill) {
- ctx.lineTo(this.area.w + this.area.x,
- this.area.h + this.area.y);
- ctx.lineTo(this.area.x, this.area.y + this.area.h);
- ctx.closePath();
- }
};
if (this.options.shouldFill) {
bind(makePath, this)(context);
+ context.lineTo(this.area.w + this.area.x, this.area.h + this.area.y);
+ context.lineTo(this.area.x, this.area.y + this.area.h);
+ context.closePath();
context.fill();
}
if (this.options.shouldStroke) {
@@ -311,7 +308,7 @@ PlotKit.CanvasRenderer.prototype._renderPieChart = function() {
context.arc(centerx, centery, radius,
slices[i].startAngle - Math.PI/2,
slices[i].endAngle - Math.PI/2,
- false);
+ slices[i].fraction == 1);
context.lineTo(centerx, centery);
context.closePath();
};
View
@@ -246,21 +246,13 @@ PlotKit.Layout.prototype.hitTest = function(x, y) {
}
else if (this.style == "pie") {
- x = 2 * x - 0.5;
var dist = Math.sqrt((y-0.5)*(y-0.5) + (x-0.5)*(x-0.5));
if (dist > this.options.pieRadius)
return null;
// TODO: actually doesn't work if we don't know how the Canvas
// lays it out, need to fix!
- var angle = 0.0;
- if (y < 0.5 && x < 0.5) {
- angle = Math.atan2(y - 0.5, x - 0.5) + 5 * Math.PI/2;
- }
- else {
- angle = Math.atan2(y - 0.5, x - 0.5) + Math.PI/2;
- }
-
+ var angle = Math.atan2(y - 0.5, x - 0.5) - Math.PI/2;
for (var i = 0; i < this.slices.length; i++) {
var slice = this.slices[i];
if (slice.startAngle < angle && slice.endAngle >= angle)

0 comments on commit c58807c

Please sign in to comment.