mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-24 17:16:52 +01:00
some duplicate code cleanup
This commit is contained in:
@@ -52,12 +52,30 @@
|
||||
},
|
||||
|
||||
draw: function() {
|
||||
var _this = this;
|
||||
|
||||
var vm = this._view;
|
||||
var ctx = this._chart.ctx;
|
||||
var first = this._children[0];
|
||||
var last = this._children[this._children.length - 1];
|
||||
|
||||
function loopBackToStart() {
|
||||
if (!first._view.skip) {
|
||||
// Draw a bezier line from last to first
|
||||
ctx.bezierCurveTo(
|
||||
last._view.controlPointNextX,
|
||||
last._view.controlPointNextY,
|
||||
first._view.controlPointPreviousX,
|
||||
first._view.controlPointPreviousY,
|
||||
first._view.x,
|
||||
first._view.y
|
||||
);
|
||||
} else {
|
||||
// Go to center
|
||||
ctx.lineTo(_this._view.scaleZero.x, _this._view.scaleZero.y);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.save();
|
||||
|
||||
// If we had points and want to fill this line, do so.
|
||||
@@ -91,20 +109,7 @@
|
||||
|
||||
// For radial scales, loop back around to the first point
|
||||
if (this._loop) {
|
||||
if (!first._view.skip) {
|
||||
// Draw a bezier line
|
||||
ctx.bezierCurveTo(
|
||||
last._view.controlPointNextX,
|
||||
last._view.controlPointNextY,
|
||||
first._view.controlPointPreviousX,
|
||||
first._view.controlPointPreviousY,
|
||||
first._view.x,
|
||||
first._view.y
|
||||
);
|
||||
} else {
|
||||
// Go to center
|
||||
ctx.lineTo(this._view.scaleZero.x, this._view.scaleZero.y);
|
||||
}
|
||||
loopBackToStart();
|
||||
} else {
|
||||
//Round off the line by going to the base of the chart, back to the start, then fill.
|
||||
ctx.lineTo(this._children[this._children.length - 1]._view.x, vm.scaleZero);
|
||||
@@ -147,20 +152,7 @@
|
||||
}, this);
|
||||
|
||||
if (this._loop) {
|
||||
if (!first._view.skip) {
|
||||
// Draw a bezier line
|
||||
ctx.bezierCurveTo(
|
||||
last._view.controlPointNextX,
|
||||
last._view.controlPointNextY,
|
||||
first._view.controlPointPreviousX,
|
||||
first._view.controlPointPreviousY,
|
||||
first._view.x,
|
||||
first._view.y
|
||||
);
|
||||
} else {
|
||||
// Go to center
|
||||
ctx.lineTo(this._view.scaleZero.x, this._view.scaleZero.y);
|
||||
}
|
||||
loopBackToStart();
|
||||
}
|
||||
|
||||
ctx.stroke();
|
||||
|
||||
Reference in New Issue
Block a user