Useful TypeScript functions for data visualization in journalism projects. Part of the journalism library.
The library is maintained by Nael Shiab, computational journalist and senior data producer for CBC News.
To learn how to use this library and more, check out Code Like a Journalist, a free and open-source data analysis and data visualization course in TypeScript. You might also find simple-data-analysis useful.
npm install @nshiab/journalism-dataviz
import { logBarChart } from "@nshiab/journalism-dataviz";
logBarChart(
[
{ country: "Canada", count: 40 },
{ country: "France", count: 25 },
],
"country",
"count",
);
To start a data project with folders, configuration and documentation for AI agents, run:
npx @nshiab/setup-data-project
For browser projects, use the /web entry point with a browser bundler.
import { rewind } from "@nshiab/journalism-dataviz/web";
const polygon = {
type: "Polygon",
coordinates: [
[
[0, 0],
[1, 0],
[1, 1],
[0, 0],
],
],
};
const rewound = rewind(polygon);
See CONTRIBUTING.md for development commands.