javascript - Merge two object arrays for Chart -


i've 2 arrays i'm going merge , load in chart.

range = date array generated moment.js, there date of every day in example 1 month or specific date range 1 attribute count: "0"

enter image description here

data = fetched data database through backbone

enter image description here

now want set atrribute count data count, date same in both arrays. i'm using lodash...

_.foreach(range, function(n) {      console.log(n.date.substring(0, date.length-6));     // if n.date = date data replace count value data array   }); 

thanks help

you can use _.find match items in range ones in data.

_.foreach(range, function(r) {     var d = _.find(data, {date: r.date}); //find item in "data" date matching r.date     if(d) {          r.count = d.count;     } }); 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -