我有来自示例1.js的代码(链接在下面给出) 这里变量json包含json数据,而不是在此文件中指定此数据,我想从另一个文件中引用,这将有助于我使protovis树形图动态化。
我是json的新手我不知道如何将来自另一个文件的商店json数据引用到变量中 完整代码可在此链接http://thejit.org/static/v20/Jit/Examples/Treemap/example1.js
中找到 function init(){
//init data
var json = {
"children": [
{
"children": [
{
"children": [],
"data": {
"playcount": "276",
"$color": "#8E7032",
"image": "http://userserve-ak.last.fm/serve/300x300/11403219.jpg",
"$area": 276
},
"id": "album-Thirteenth Step",
"name": "Thirteenth Step"
},
{
"children": [],
"data": {
"playcount": "271",
"$color": "#906E32",
"image": "http://userserve-ak.last.fm/serve/300x300/11393921.jpg",
"$area": 271
},
"id": "album-Mer De Noms",
"name": "Mer De Noms"
}
],
"data": {
"playcount": 547,
"$area": 547
},
"id": "artist_A Perfect Circle",
"name": "A Perfect Circle"
},
{
"children": [
{
"children": [],
"data": {
"playcount": "209",
"$color": "#AA5532",
"image": "http://userserve-ak.last.fm/serve/300x300/32349839.jpg",
"$area": 209
},
"id": "album-Above",
"name": "Above"
}
],
"data": {
"playcount": 209,
"$area": 209
},
"id": "artist_Mad Season",
"name": "Mad Season"
}
......