Is there anyway to return other data inside of the javascript treemap json? Is there anyway to return other data inside of the javascript treemap json? json json

Is there anyway to return other data inside of the javascript treemap json?


What you would need to do is a single call in which you work out the callback yourself. Here the json would be a structure like

var data = {  heatmap_data: {}  other_data: {}}

and next call

tm.loadJSON(data.heatmap_data);  

to load the heatmap data and use all the other data to your own liking. That should do the trick right? At least, that is if loadJSON takes an object as seems to be the case. Still, this answer seems too simple, so I might be totally missing the point.


You have a defined structure for your TreeMap, basically you have every node with keys id, name, data and children. As far as I read in the docs, there is no restriction on other keys. So you can add extra keys inside the data attribute.

For example your json response could be like this:

{    "data": {        "myCustomData": { /* your data here */ }    },    "id": "root",    "name": "Top Albums",    "children": [        {            "data": {                "playcount": 547,                "$area": 547,                 "myCustomData": { /* your data here */ }            },            "id": "artist_A Perfect Circle",            "name": "A Perfect Circle"        }    ]}

When you want to use your extra data you do this:

... onClick: function(node) {      ...      if( node.data.myCustomData ){           /*** you have data, do something here ***/      }}

Here you have a LIVE EXAMPLE with an alert when you click on nodes with myCustomData. mouse over the "Make yourself" box on top left corner to see custom data in the tooltip and an alert with the custom data on click.

Search the code for "mycustomdata" to see how it's done.