Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Refactor logic into shared Element method
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnick committed Jul 8, 2014
1 parent 2f59921 commit fdfa991
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Chart.Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion src/Chart.Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down Expand Up @@ -1037,6 +1037,9 @@
x : this.x,
y : this.y
};
},
hasValue: function(){
return isNumber(this.value);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/Chart.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
}
});
Expand Down

0 comments on commit fdfa991

Please sign in to comment.