Reputation: 36894
I recently started using d3js and I am currently trying to figure out how to use transitions.
I got the TreeMap example working with my own json file.
My question is: How can I change the layout with a transition from the treemap
to a tree
?
My json data looks like this:
{"name": "OS",
"children": [
{"name": "Linux x64",
"children": [
{"name": "Linux (amd64)", "size": 58154},
{"name": "Linux (ia64)", "size": 3}
]
},
{"name": "Linux x86",
"children": [
{"name": "Linux (i386)", "size": 12269}
]
},
{"name": "Mac OS x64",
"children": [
{"name": "Mac OS X (x86_64)", "size": 53118}
]
},
{"name": "Mac OS x86",
"children": [
{"name": "Mac OS X (i386)", "size": 409}
]
},
{"name": "SunOS x64",
"children": [
{"name": "SunOS (amd64)", "size": 3}
]
},
{"name": "SunOS x86",
"children": [
{"name": "SunOS (x86)", "size": 8}
]
},
{"name": "Windows x64",
"children": [
{"name": "Windows 2003 (amd64)", "size": 32},
{"name": "Windows 7 (amd64)", "size": 25492},
{"name": "Windows 8 (amd64)", "size": 19},
{"name": "Windows NT (unknown) (amd64)", "size": 76},
{"name": "Windows Server 2008 (amd64)", "size": 349},
{"name": "Windows Server 2008 R2 (amd64)", "size": 428},
{"name": "Windows Vista (amd64)", "size": 1337},
{"name": "Windows XP (amd64)", "size": 1284}
]
},
{"name": "Windows x86",
"children": [
{"name": "Windows 2000 (x86)", "size": 147},
{"name": "Windows 2003 (x86)", "size": 390},
{"name": "Windows 7 (x86)", "size": 17933},
{"name": "Windows 8 (x86)", "size": 10},
{"name": "Windows 95 (x86)", "size": 2},
{"name": "Windows NT (unknown) (x86)", "size": 13},
{"name": "Windows Server 2008 (x86)", "size": 19},
{"name": "Windows Server 2008 R2 (x86)", "size": 43},
{"name": "Windows Vista (x86)", "size": 4815},
{"name": "Windows XP (x86)", "size": 34545}
]
}
]
}
I didn't really change the example code, but I can post it, if it helps.
Upvotes: 3
Views: 603
Reputation: 6025
You can't make transition from a TreeMap to Tree... Transition change styles or attributes but you cant make a transition from one layout to another.
For dummies: transitions is like change apple's color from red to green or to change it's size, but you can't change an apple by an orange.
Upvotes: 1