本文整理汇总了TypeScript中d3-request.json函数的典型用法代码示例。如果您正苦于以下问题:TypeScript json函数的具体用法?TypeScript json怎么用?TypeScript json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: json
function json(innertext:string, sub: Element, url: string, fn: (data: any) => void) {
let i = document.createElement('i');
i.classList.add("loading");
i.classList.add("fa");
i.classList.add("fa-spinner");
i.classList.add("fa-pulse");
sub.innerHTML = "";
sub.appendChild(i);
(sub as any).onclick = function() {
json(innertext, sub, url, fn);
}
d3_json(url, (error: any, data: any) => {
if (error) {
i.classList.remove("fa-spinner");
i.classList.remove("fa-pulse");
i.classList.add("fa-refresh");
i.classList.add("connection-error");
let text = document.createElement('span');
text.classList.add("error-text")
text.innerHTML = innertext;
i.appendChild(text);
} else {
(sub as any).onclick = function() {
}
fn(data);
}
});
}
开发者ID:gems-uff,项目名称:noworkflow,代码行数:34,代码来源:web.ts
示例2: Promise
this._initPromise = new Promise((resolve, reject) => {
if (usCounties) {
resolve(usCounties);
}
d3Json(`${topoJsonFolder()}/us-counties.json`, function (_usCounties) {
usCounties = _usCounties;
resolve(usCounties);
});
}).then((usCounties: any) => {
开发者ID:GordonSmith,项目名称:Visualization,代码行数:9,代码来源:USCounties.ts
示例3: d3Json
d3Json(`${topoJsonFolder()}/${context.region()}.json`, function (region) {
context._choroTopology = region;
context._choroTopologyObjects = region.objects.PolbndA;
context._choroTopologyFeatures = topojson.feature(context._choroTopology, context._choroTopologyObjects).features;
d3Json(`${topoJsonFolder()}/${context.region()}_idx.json`, indexLoad)
.on("error", function (err) {
indexLoad({});
})
;
function indexLoad(index) {
context._choroTopologyIndex = index;
resolve();
}
});
开发者ID:GordonSmith,项目名称:Visualization,代码行数:16,代码来源:TopoJSONChoropleth.ts
示例4: Promise
this._initPromise = new Promise((resolve, reject) => {
if (usCounties) {
resolve();
}
d3Json(`${topoJsonFolder()}/us-counties.json`, function (_usCounties) {
usCounties = _usCounties;
features = topojson.feature(usCounties.topology, usCounties.topology.objects.counties).features;
rFeatures = {};
for (const key in features) {
if (features[key].id) {
rFeatures[features[key].id] = features[key];
}
}
resolve();
});
});
开发者ID:GordonSmith,项目名称:Visualization,代码行数:16,代码来源:TopoJSON.ts
示例5: function
// HTML Request
// -------------------------------------------------------------------------------
const html: d3Request.Request = d3Request.html(url);
const htmlWithCallback: d3Request.Request = d3Request.html(url, function(error, data) {
const that: d3Request.Request = this;
const err: any = error;
const d: DocumentFragment = data;
console.log(d);
});
// -------------------------------------------------------------------------------
// JSON Request
// -------------------------------------------------------------------------------
const json: d3Request.Request = d3Request.json(url);
const jsonWithCallback: d3Request.Request = d3Request.json<ResponseDatumGET[]>(url, function(error, data) {
const that: d3Request.Request = this;
const err: any = error;
const d: ResponseDatumGET[] = data;
console.log(d);
});
// -------------------------------------------------------------------------------
// Text Request
// -------------------------------------------------------------------------------
const text: d3Request.Request = d3Request.text(url);
const textWithCallback: d3Request.Request = d3Request.text(url, function(error, data) {
const that: d3Request.Request = this;
const err: any = error;
开发者ID:danmarshall,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-request-tests.ts
示例6: Promise
return new Promise((res, rej) => {
json(`http://localhost:5000/api/infographics/${this._query.country}/${this._query.graph}`, (data) => {
res(data);
});
})
开发者ID:Ao21,项目名称:rollup-test,代码行数:5,代码来源:data.ts
注:本文中的d3-request.json函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论