本文整理汇总了TypeScript中d3-dsv.dsvFormat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dsvFormat函数的具体用法?TypeScript dsvFormat怎么用?TypeScript dsvFormat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dsvFormat函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: parse
/**
* Parse the content using the model's delimiter.
*
* #### Notes
* This method will always return parsed content that has at most the display
* limit worth of rows, currently maxing out at 1000 rows.
*/
parse(): dsv.DSVParsedArray<dsv.DSVRowString> {
let output = dsv.dsvFormat(this._delimiter).parse(this._content);
let available = output.length;
let maximum = DISPLAY_LIMIT;
if (available > maximum) {
// Mutate the array instead of slicing in order to conserve memory.
output.splice(maximum);
this.maxExceeded.emit({ available, maximum });
}
return output;
}
示例2:
str = d3Dsv.tsvFormatRows(parseRowsMappedArray.map((d) => [
d.year ? d.year.getFullYear().toString() : '',
d.make,
d.model,
d.length.toString()
]));
// ------------------------------------------------------------------------------------------
// Test DSV Generalized Parsers and Formatters
// ------------------------------------------------------------------------------------------
// Create custom-delimited Parser/Formatter =================================================
let dsv: d3Dsv.DSV;
dsv = d3Dsv.dsvFormat('|');
// parse(...) ============================================================================
// without row mapper -----------------------------------------------------------------------
parseArray = dsv.parse(pipedTestStringWithHeader);
rowArrayHeader = dsv.parse<Headers>(csvTestStringWithHeader);
// with row mapper ---------------------------------------------------------------------------
parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns) => {
const rr: d3Dsv.DSVRowString = rawRow;
const i: number = index;
const c: string[] = columns;
const d: number | null = rr.Year ? +rr.Year! : null;