Refactor logic into shared Element method

This commit is contained in:
Nick Downie
2014-07-08 22:44:55 +01:00
parent 2f59921f7a
commit fdfa9912e8
3 changed files with 8 additions and 5 deletions

View File

@@ -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({

View File

@@ -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);
}
});

View File

@@ -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();
}
});