access the array->object -> array values

162 Views Asked by At

I'm trying to access the elements of "values" array of object wns of array data in d3 , how can i ? i need to access these values to create bars.

 var data =  [{
             "labels": [ "scn1","scn2" ]},{
                "wns": [ {
                        "label": "scn1",
                       "values": [ -0.06,
                                   -0.15,
                                    -0.21]},
                         {
                        "label": "scn2",
                       "values": [ -0.04,
                                   -0.13,
                                   -0.41 ]} 

                        ]
            }];

say i need to access values "-0.06" from data-> wns[0]-> values[0] and "-0.04" from data -> wns[1] -> values[0].

d3.select("body").selectAll("p").data(data.wns[0].values[0]).enter().append(p).text ("place wns value") 

or

d3.select("body").selectAll("p").data(data.wns[1].values[0]).enter().append(p).text ("cts wns value")

at JS console do not bind anything need help.context is that a new-bee trying to visualize data from a table...

Thanks

<<<<<<===============FOLLOWING IS WHAT IM TRYING TO ACHIEVE=============>>>>>>>

Have a table with two rows and three columns.first cell in the Row are the labels needed for bar chart, columns are the "WNS" values where each column represents a stage.

                WNS
scn1     -0.06 -0.15 -0.21
scn2     -0.04 -0.13 -0.41

I need to create a grouped bar chart where all the numbers in a row form a group.

0

There are 0 best solutions below