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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -