當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript d3-request.json函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。