javascript - d3 line.defined doesn't draw zero value -


fi've made multiline chart , want manage empty values. have 2 kinds of empty value '' , ' ' use map csv

var column = color.domain().map(function(name) {   return {     name: name,     values: data.map(function(d) {       if(d[name] === '' || d[name] === ' '){         //if data empty store in d.vale string         return {name: name, id: d.id, value: d[name]};       }       else{         //if value not empty store in d.value number , replacing coma dot (replacedot function)         return {name: name, id: d.id, value: +replace(replacedot(d[name]))};       }      })   }; }); 

than inside line.defined check if d.vale not string , if not return it:

var line = d3.svg.line() .defined(function(d) { if(typeof d.value !== 'string'){ return d.value;}}) 

this work fine escape empty value, if there 0.0 value in dataset escaped to...

how can fix it?

thanks daniele

the .defined function supposed return true/false depending on whether line defined or not. current function returns nothing or value. it's safer return true/false explicitly relying on correct interpretation of returned value, i.e. use

.defined(function(d) { return (typeof d.value !== 'string'); }) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -