d3.js - Getting same value from javascript function -


i using following code different different colors using d3.scale.category10(). here code:

function getdrawcolor(i) {     var colors = d3.scale.category10(); //    for(var j=0;j<5;j++) //    { //        alert(colors(j)); //    }           return colors(i); } 

when try print colors using commented loop, getting different different colors. when calling method different valued of i, getting same color(i.e. color(0)),regardless of value of i. printed value of i,there no problem but, getting first color.

declare colors in global, , use inside of function below

var colors = d3.scale.category10(); function getdrawcolor(i) {   return colors(i); } 

hope work you...


Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

ruby - Net::HTTP extremely slow responses for HTTPS requests -