来自另一个文件的 InfoVis Treemap 动态数据

发布于 2024-12-28 04:56:55 字数 1580 浏览 1 评论 0原文

我有示例 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文