javascript - Using a variable in D3 data method to pull JSON data -
Then I am pulling data from JSON code, but I want data to be one variable (which I will give the user menu ) And no direct reference.
I was just wondering what could happen after 'D'. Be a variable? If not, I would love to hear some of the proposed solutions. Here is an example of a solution that I am hoping to achieve.
canvas.sctall ("circle") .data (finaldataset) .enter (); Var userbillultviarb 1 = some stringmediacheckmenen; Var userbillultvierable2 = some string mediatectatmain; Var userbillwirewire 3 = some stringmediacheckman; ("C", function (D) {Return D. Eusubbuilt semimetube 2}). ("Whistle" ("cc", function (d) {return d.usbalbt variable 1}. Rrt ("c" r ", function (d) {return d.userBuiltVariable3});
JSON code looks like this;
"country": "Wales", "BoyWaryday 1102": "0.9", "BoySensawack-1102": "1.2", "Boyleththonau 1102 "1.9", "Boydant 1102": "96.0"
This short story means gender - how often they smoke - how old are they - which data were taken Was it? The second line is showing boys, in the year 2002 Smokes at the age of 11. Other examples include "GirlOneWeek 1510" or "Girlfriend 1306", so this variable will be created by the user with a select menu. Any help greatly appreciated - Thanks
Yes, this is done very easily. The solution will not be anything from D3 copy, just javascript basics.
If you have JavaScript object, you have several ways You can ask your properties.
First of all, and the most common one is dot notation, which you are already using in your code.
var myObject = {foo: 'bar'}; Console.log ('dot notation', foo.bar);
Using another, less common size, square bracket, with it, you can use any variable (but it only makes sense to use strings ).
var myObject = {foo: 'bar'}; Var myProperty = 'foo'; Console.log ('square brackets', foo [myProperty]);
Now apply it to your example code:
var user user1 = some stringmapmaxchannel; Var userbillultvierable2 = some string mediatectatmain; Var userbillwirewire 3 = some stringmediacheckman; ("C", function (d) {return d [userbilt semen 2]}) .attr ("cac", function (d) {return d [userbelt variable 1}}). ("R", function (d) {return d [userbelt variable 3]});
... you should do what you need.
HH!
Comments
Post a Comment