mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-05 16:04:03 +01:00
Refactor logic into shared Element method
This commit is contained in:
@@ -275,7 +275,7 @@
|
||||
//Draw all the bars for each dataset
|
||||
helpers.each(this.datasets,function(dataset,datasetIndex){
|
||||
helpers.each(dataset.bars,function(bar,index){
|
||||
if (helpers.isNumber(bar.value)){
|
||||
if (bar.hasValue()){
|
||||
bar.base = this.scale.endPoint;
|
||||
//Transition then draw
|
||||
bar.transition({
|
||||
|
||||
@@ -873,7 +873,7 @@
|
||||
yMin;
|
||||
helpers.each(this.datasets, function(dataset){
|
||||
dataCollection = dataset.points || dataset.bars || dataset.segments;
|
||||
if (dataCollection[dataIndex] && helpers.isNumber(dataCollection[dataIndex].value)){
|
||||
if (dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()){
|
||||
Elements.push(dataCollection[dataIndex]);
|
||||
}
|
||||
});
|
||||
@@ -1037,6 +1037,9 @@
|
||||
x : this.x,
|
||||
y : this.y
|
||||
};
|
||||
},
|
||||
hasValue: function(){
|
||||
return isNumber(this.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@
|
||||
//We can use this extra loop to calculate the control points of this dataset also in this loop
|
||||
|
||||
helpers.each(dataset.points,function(point,index){
|
||||
if (helpers.isNumber(point.value)){
|
||||
if (point.hasValue()){
|
||||
point.transition({
|
||||
y : this.scale.calculateY(point.value),
|
||||
x : this.scale.calculateX(index)
|
||||
@@ -293,7 +293,7 @@
|
||||
ctx.strokeStyle = dataset.strokeColor;
|
||||
ctx.beginPath();
|
||||
helpers.each(dataset.points,function(point,index){
|
||||
if (helpers.isNumber(point.value)){
|
||||
if (point.hasValue()){
|
||||
if (index>0){
|
||||
if(this.options.bezierCurve){
|
||||
ctx.bezierCurveTo(
|
||||
@@ -331,7 +331,7 @@
|
||||
//A little inefficient double looping, but better than the line
|
||||
//lagging behind the point positions
|
||||
helpers.each(dataset.points,function(point){
|
||||
if (helpers.isNumber(point.value)){
|
||||
if (point.hasValue()){
|
||||
point.draw();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user