-
MikeSeptember 3, 2016 at 8:56 am #6432
I was trying to do the same thing. Didn’t get there, here is a description of my attempts
I used console.log(nest) and console.log(data) in the loadData() function and initialize() to try and see the form of the data. I was hoping it would be simple like in the references example above. I went am using a slightly different referenced example, but I believe both examples from blocks use the same data.
I updated the code below to try and sway the example code for flare.json
I copied this file and put it into the data folder:
https://bl.ocks.org/mbostock/raw/4063550/flare.jsonThen in loadData I tried this, I could see the object was being read in, but kept throwing errors.
I was tring to change the properties in the initialize function to make it appropriate for the new data
function loadData() { d3.json("data/flare.json", function(error, flare) { if (error) throw error; //data=JSON.parse(flare); I tried this but took it out data=flare; initialize(); }); }
Then in the initilize function I tried to follow the comments to update the properties to the new data set
function initialize() { // removed code here just to show the parts I was editing console.log(data) viz.data(data) // flare.json is hierarchial array. should this be viz.data(function(d){return d}) // Expects hierarchical array of objects. .width(600) // Width of component .height(600) // Height of component .children(data.children) // Denotes the property that holds child object array //flare.json has the nested array inside of "children" I also tried d.children .key(data.name) // Unique key .value(data.size) // The property of the datum that will be used for the branch and node size .fixedSpan(-1) // fixedSpan > 0 will use this pixel value for horizontal spread versus auto size based on viz width .label(data.name) .on("measure",onMeasure) // Make any measurement changes .on("mouseover",onMouseOver) // mouseover callback - all viz components issue these events .on("mouseout",onMouseOut) // mouseout callback - all viz components issue these events .on("click",onClick); // mouseout callback - all viz components issue these events
You must be logged in to reply to this topic.
© 2024 — vizuly.io