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


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

本文整理匯總了TypeScript中d3-request.csv函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript csv函數的具體用法?TypeScript csv怎麽用?TypeScript csv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了csv函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: onCsv

function onCsv(f: (csv: [number, number][]) => void) : void {
	csv('ny-vs-sf.csv')
	.row((d: {NY: string, SF: string}) => [
		parseFloat(d.NY.split(';')[0]),
		parseFloat(d.SF.split(';')[0]),
	])
	.get((error: null, data: [number, number][]) => {
		if (error != null) {
			alert('Data can\'t be downloaded or parsed')
			return
		}
		f(data)
	})
}
開發者ID:streamcode9,項目名稱:svg-time-series,代碼行數:14,代碼來源:index.ts

示例2: function

// -------------------------------------------------------------------------------

const xml: d3Request.Request = d3Request.xml(url);
const xmlWithCallback: d3Request.Request = d3Request.xml(url, function(error, data) {
    const that: d3Request.Request = this;
    const err: any = error;
    const d: any = data;
    console.log(d);
});

// -------------------------------------------------------------------------------
// CSV Request
// -------------------------------------------------------------------------------

// url only
let csvRequest: d3Request.DsvRequest = d3Request.csv(url);

// url and callback for response handling
const csvRequestWithCallback: d3Request.DsvRequest = d3Request.csv(url, function(error, data) {
    const that: d3Request.Request = this;
    const err: any = error;
    const d: DSVParsedArray<DSVRowString> = data;
    console.log(d);
});

// url, row mapping function and callback for response handling
const csvRequestWithRowWithCallback: d3Request.DsvRequest = d3Request.csv<ResponseDatumGET>(url,
    (rawRow, index, columns) => {
        const rr: DSVRowString = rawRow;
        const i: number = index;
        const cols: string[] = columns;
開發者ID:danmarshall,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:d3-request-tests.ts

示例3: require

ďťżdeclare const require: Function
const d3request = require('d3-request')
const d3shape = require('d3-shape')
const d3selection = require('d3-selection')
import measureFPS = require('../../measure')
import draw = require('./draw')
import drawModelCS = require('./drawModelCS')

const startDate = new Date()
d3request
	.csv('ny-vs-sf.csv')
	.row((d: any) => [
		parseFloat(d.NY.split(';')[0]),
		parseFloat(d.SF.split(';')[0])
	])
	.get((error: any, data: any[]) => {
		if (error != null)
		{
			alert('Data can\'t be downloaded or parsed')
			return
		}

		const onPath = (path: any) => {
			 path.attr('d', (cityIdx: number) =>
				d3shape.line()
                     .defined((d: number[]) => d[cityIdx])
                     .x((d: number[], i: number) => i)
					.y((d: number[]) => d[cityIdx])
					.call(null, data)
			)
		}
開發者ID:streamcode9,項目名稱:svg-time-series,代碼行數:31,代碼來源:index.ts


注:本文中的d3-request.csv函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。