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

Commit

Permalink
New methods for array finding
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnick committed Aug 3, 2014
1 parent 09c0f33 commit bd25b5c
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/Chart.Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,41 @@
return -1;
}
},
where = helpers.where = function(collection, filterCallback){
var filtered = [];

helpers.each(collection, function(item){
if (filterCallback(item)){
filtered.push(item);
}
});

return filtered;
},
findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex){
// Default to start of the array
if (!startIndex){
startIndex = -1;
}
for (var i = startIndex + 1; i < arrayToSearch.length; i++) {
var currentItem = arrayToSearch[i];
if (filterCallback(currentItem)){
return currentItem;
}
};
},
findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex){
// Default to end of the array
if (!startIndex){
startIndex = arrayToSearch.length;
}
for (var i = startIndex - 1; i >= 0; i--) {
var currentItem = arrayToSearch[i];
if (filterCallback(currentItem)){
return currentItem;
}
};
},
inherits = helpers.inherits = function(extensions){
//Basic javascript inheritance based on the model created in Backbone.js
var parent = this;
Expand Down Expand Up @@ -717,7 +752,7 @@
var ctx = chart.ctx,
width = chart.canvas.width,
height = chart.canvas.height;
//console.log(width + " x " + height);

if (window.devicePixelRatio) {
ctx.canvas.style.width = width + "px";
ctx.canvas.style.height = height + "px";
Expand Down

0 comments on commit bd25b5c

Please sign in to comment.