“导出”一个使用附属对象-d3.js的支路示例 [英] "Exporting" a Tributary example that makes use of the tributary object - d3.js

查看:110
本文介绍了“导出”一个使用附属对象-d3.js的支路示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

支路(d3.js的快速原型开发环境)有一些非常好的功能。其中一个是支路对象,它使您可以轻松访问您的数据文件。例如,要在支流中加载一个json文件(example.json),我可以这样做:

Tributary (a rapid prototyping environment for d3.js) has some really great features. One of which is the tributary object which gives you easy access to your data files. For example, to load a json file (example.json) in tributary I can do something like:

var example = tributary.example;

我的问题是,如何提取一个支流示例,和Javascript代码。例如,我尝试使用此演示,将其包装在以下函数中,但找不到成功:

My question is, how can I "extract" a tributary example that is using the tributary object into HTML and Javascript code. For example, I tried with this demo, by wrapping it in the following functions, but couldn't find success:

 d3.json("costofliving.json", function(col) {
  d3.json("worldcountries.json", function(countries) {
  });
 });

有关如何从加载外部json文件到html /将非常感谢。

Any advice on how to go from a tributary demo that loads external json files to a HTML/Javascript demo would be greatly appreciated.

推荐答案

将svg附加到dom和宽度和高度属性...此外使变量col和国家可访问....我已经尝试演示,它工作正常为我..

Append the svg to the dom and the width and height attributes... Moreover make the variables col and countries accessible ....I have tried the demo and it worked fine for me..

这篇关于“导出”一个使用附属对象-d3.js的支路示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆