来自另一个文件的 InfoVis Treemap 动态数据
我有示例 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"
}
......
I have code from example 1.js (link give below)
here that variable json contains json data,instead of specify this data in this file i want to refer from another file which will help me making the protovis treemap dynamic.
I am new to json i don't know how to refer store json data from another file into a variable
full code is available in this link 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"
}
......
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论