npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rehype-timeseries-chart

v0.0.29

Published

Rehype plugin to render CSV code blocks as SVG timeseries charts

Readme

rehype-timeseries-chart

npm version MIT License

rehype plugin to transform CSV data into responsive SVG timeseries charts.

Contents

What is this?

This package is a rehype plugin that transforms CSV data in fenced code blocks into responsive SVG timeseries charts. It's built for documentation sites, blogs, and any content pipeline where you want to embed lightweight data visualizations without external dependencies.

When should I use this?

Use this plugin when you:

  • Want to embed simple, lightweight data visualizations in Markdown
  • Are building documentation sites with tools like MDX, Docusaurus, or Next.js
  • Need server-side rendering of charts without client-side JavaScript
  • Want to convert CSV data from LLM responses into visual charts (LibreChat)
  • Prefer static SVG charts over complex interactive charting libraries

Don't use this plugin when you need advanced interactions like tooltips, zooming, or real-time data updates. For those cases, consider full JavaScript charting libraries like Chart.js or D3.

Install

This package is ESM only. In Node.js (version 18+), install with npm:

npm install rehype-timeseries-chart

Use

Say we have the following Markdown:

### Chart
```csv
Date,V1,V2,V3
2025-01-01 01:00:00,10,90,30
2025-01-01 02:00:00,90,10,70
2025-01-01 03:00:00,10,90,30
2025-01-01 04:00:00,90,10,70
2025-01-01 05:00:00,10,90,30
2025-01-01 06:00:00,90,10,70
2025-01-01 07:00:00,10,90,30
2025-01-01 08:00:00,90,10,70
```

…now running node example.js yields:

<div class="timeseries-chart-container">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 300" preserveAspectRatio="none" width="100%" height="100%">
    <!-- SVG chart content -->
  </svg>
</div>

Integration with remark

To use with remark (for Markdown processing):

import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeTimeseriesChart from 'rehype-timeseries-chart'
import rehypeStringify from 'rehype-stringify'

const file = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeTimeseriesChart, {
    title: 'Sales Performance',
    textColor: 'var(--text-primary)',
    backgroundColor: 'var(--background-secondary)'
  })
  .use(rehypeStringify)
  .process(`# Sales Report

\`\`\`csv
Date,Revenue,Users
2024-01-01,1000,150
2024-02-01,1200,180
2024-03-01,1500,220
\`\`\``)

console.log(String(file))

API

The default export is rehypeTimeseriesChart.

unified().use(rehypeTimeseriesChart,{...}])

Options

Configuration for the plugin (TypeScript type).

Fields

| Name | Type | Default | Description | | ----------------- | --------- | ------------------------------ | ----------------------------------------------------------- | | width | number | 640 | View‑box width of the generated SVG. | | height | number | 300 | View‑box height of the generated SVG. | | title | string | — | Optional chart title rendered above the plot. | | textColor | string | "#000" | CSS color for all text elements. | | backgroundColor | string | — | Fill color for the SVG background rectangle. | | containerClass | string | "timeseries-chart-container" | Class name for the wrapping <div>. | | codeLanguage | string | "csv" | Which language class to look for on <code>. | | saveOriginal | boolean | false | Keep the original <pre><code> block inside the container. |

Examples

Basic timeseries

```csv
Date,Sales
2024-01-01,100
2024-02-01,150
2024-03-01,200
```

Multiple series with custom styling

.use(rehypeTimeseriesChart, {
  title: 'Q1 Performance Metrics',
  width: 800,
  height: 400,
  textColor: 'var(--text-primary)',
  backgroundColor: 'var(--bg-secondary)'
})
```csv
Date,Revenue,Users,Conversion Rate
2024-01-01,1000,150,6.7
2024-02-01,1200,180,6.9
2024-03-01,1500,220,7.2
```

Hourly data with a preserved original CSV code block

.use(rehypeTimeseriesChart, {
  saveOriginal: true
})
```csv
Timestamp,CPU Usage,Memory Usage
2024-01-01 00:00:00,45,2.1
2024-01-01 01:00:00,52,2.3
2024-01-01 02:00:00,38,1.9
```

Compatibility

This package is compatible with Node.js 18+.

Security

This plugin transforms CSV data into SVG markup. The plugin does not execute arbitrary code, but ensures any CSV data is from trusted sources as values are rendered verbatim in the generated HTML.

Related

LibreChat integration:

rehype-timeseries-chart

Contribute

Yes, please!

License

MIT © Denis Perov