当前位置: 首页>>代码示例>>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;未经允许,请勿转载。