
function CanvasChartPainterFactory() {
	return new CanvasChartPainter();
}
function CanvasChartPainter() {
	this.base = AbstractChartPainter;
}
CanvasChartPainter.prototype = new AbstractChartPainter;
CanvasChartPainter.prototype.create = function (el) {
	while (el.firstChild) {
		el.removeChild(el.lastChild);
	}
	this.el = el;
	this.w = el.clientWidth;
	this.h = el.clientHeight;
	this.canvas = document.createElement("canvas");
	this.canvas.width = this.w;
	this.canvas.height = this.h;
	this.canvas.style.width = this.w + "px";
	this.canvas.style.height = this.h + "px";
	el.appendChild(this.canvas);
	if ((!this.canvas.getContext) && (typeof G_vmlCanvasManager != "undefined")) {
		this.canvas = G_vmlCanvasManager.initElement(this.canvas);
	}
	this.ctx = this.canvas.getContext("2d");
};
CanvasChartPainter.prototype.getWidth = function () {
	return this.w;
};
CanvasChartPainter.prototype.getHeight = function () {
	return this.h;
};
CanvasChartPainter.prototype.fillArea = function (color, points) {
	if (points.length <= 0) {
		return;
	}
	this.ctx.fillStyle = color;
	this.ctx.beginPath();
	this.ctx.moveTo(points[0].x, points[0].y);
	for (i = 1; i < points.length; i++) {
		this.ctx.lineTo(points[i].x, points[i].y);
	}
	this.ctx.lineTo(points[0].x, points[0].y);
	this.ctx.closePath();
	this.ctx.fill();
};
CanvasChartPainter.prototype.polyLine = function (color, lineWidth, points) {
	if (points.length <= 0) {
		return;
	}
	this.ctx.lineWidth = lineWidth;
	this.ctx.strokeStyle = color;
	this.ctx.beginPath();
	this.ctx.moveTo(points[0].x, points[0].y);
	for (var i = 1; i < points.length; i++) {
		this.ctx.lineTo(points[i].x, points[i].y);
	}
	this.ctx.stroke();
};
CanvasChartPainter.prototype.fillRect = function (color, x, y, width, height) {
	this.ctx.fillStyle = color;
	this.ctx.fillRect(x, y, width, height);
};
CanvasChartPainter.prototype.line = function (color, lineWidth, x1, y1, x2, y2) {
	this.ctx.lineWidth = parseInt(lineWidth);
	this.ctx.strokeStyle = color;
	this.ctx.beginPath();
	this.ctx.moveTo(x1, y1);
	this.ctx.lineTo(x2, y2);
	this.ctx.stroke();
};
CanvasChartPainter.prototype.fillArc = function (color, centerx, centery, radius, startAngle, endAngle) {
	this.ctx.fillStyle = color;
	this.ctx.beginPath();
	this.ctx.moveTo(centerx, centery);
	startAngle = startAngle * Math.PI / 180;
	endAngle = endAngle * Math.PI / 180;
	this.ctx.arc(centerx, centery, radius, startAngle, endAngle, false);
	this.ctx.lineTo(centerx, centery);
	this.ctx.closePath();
	this.ctx.fill();
};


