d3.js: How to import csv data with float and string types -


very new d3 , javascript, have done 4 or hours trying resolve issue , haven't found solution yet.

my .csv dataset i'd use has both string , float numbers (see sample set here: http://individual.utoronto.ca/lannajin/d3/pcadummyset.csv), i'm having issues importing.

d3.csv("http://individual.utoronto.ca/lannajin/d3/pcadummyset.csv")     .row(function (d) {     return {         metric: d.metric,         var: d.var,         param: d.param,         pc1: +d.pc1, // convert "pc1" column number         pc2: +d.pc2, // convert "pc2" column number         type: d.type     }; })     .get(function (error, rows) {     console.log(rows); }); 

where i've tried variations (for line 7 & 8) as:

pc1: d.parsefloat("pc1"), pc1: parsefloat(d.pc1), pc1: d.parsefloat.pc1, 

etc.

the main problem float characters (pc1 , pc2) in form 1.0e-02 rather 0.001, means can't use "+" operator convert data float. instead, have use parsefloat function, which, unfortunately not sure how use.

when change structure solution offered importing csv without headers d3 - data both numbers , strings,

data = d3.csv.parserows("http://individual.utoronto.ca/lannajin/d3/pcadummyset.csv").map(function(row) {     return row.map(function(value, index) {         if(index == 2) {             return value;         } else {             return +value;         }     }); }); 

it's clear data being read, not plotted since pc1 , pc2 values being read in strings. tried integrate parsefloat function, still won't plot values.

help please!


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -