当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript d3-dsv.csvFormat函数代码示例

本文整理汇总了TypeScript中d3-dsv.csvFormat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript csvFormat函数的具体用法?TypeScript csvFormat怎么用?TypeScript csvFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了csvFormat函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

                    length: rr[3].length ? +rr[3] : NaN
                }
                : undefined
        )
        : null;
    return pr;
});

dateNull = parseRowsMappedArray[0].year;
strMaybe = parseRowsMappedArray[0].make;
strMaybe = parseRowsMappedArray[0].model;
num = parseRowsMappedArray[0].length;

// csvFormat(...) ============================================================================

str = d3Dsv.csvFormat(parseRowsMappedArray);
str = d3Dsv.csvFormat(parseRowsMappedArray, columns);

// csvFormatRows(...) ========================================================================

str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
    d.year ? d.year.getFullYear().toString() : '',
    d.make,
    d.model,
    d.length.toString()
]));

// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------
开发者ID:github-account-because-they-want-it,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-dsv-tests.ts

示例2: Date

            d > 1997
                ? {
                    year: new Date(d, 0, 1),
                    make: rr[1].length ? rr[1] : "Missing Value",
                    model: rr[2].length ? rr[2] : "Missing Value",
                    length: rr[3].length ? +rr[3] : NaN
                }
                : undefined
        )
        : null;
    return pr;
});

// csvFormat(...) ============================================================================

str = d3Dsv.csvFormat(parseRowsMappedArray);
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "length"]);
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "unknown"]); // $ExpectError

// csvFormatRows(...) ========================================================================

str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d) => [
    d.year ? d.year.getFullYear().toString() : '',
    d.make,
    d.model,
    d.length.toString()
]));

// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-dsv-tests.ts

示例3: tally

for (const row of airlines) {
    tally(info.airportDict, row.airport.code, row.airport);
    tally(info.carrierDict, row.carrier.code, row.carrier);

    const timeParts = row.time.label.split("/");
    info.stats.push({
        year: timeParts[0],
        month: timeParts[1],
        airport: row.airport.code,
        carrier: row.carrier.code,
        ontime: row.statistics.flights["on time"],
        cancelled: row.statistics.flights.cancelled,
        delayed: row.statistics.flights.delayed,
        diverted: row.statistics.flights.diverted,
        delay: row.statistics["minutes delayed"].total
    });
}

for (const key in info.airportDict) {
    info.airports.push(info.airportDict[key]);
}

for (const key in info.carrierDict) {
    info.carriers.push(info.carrierDict[key]);
}

fs.writeFile("data/airports.csv", csvFormat(info.airports), "utf8", () => { });
fs.writeFile("data/carriers.csv", csvFormat(info.carriers), "utf8", () => { });
fs.writeFile("data/stats.csv", csvFormat(info.stats), "utf8", () => { });
开发者ID:GordonSmith,项目名称:Visualization,代码行数:29,代码来源:index.ts


注:本文中的d3-dsv.csvFormat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。