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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@summerforeverco/duck-plot

v0.0.32

Published

DuckPlot is an open-source JavaScript library that allows you to quickly generate charts with [Observable Plot](https://github.com/observablehq/plot) when working with [DuckDB](https://duckdb.org/).

Downloads

308

Readme

DuckPlot 🦆📈

DuckPlot is an open-source JavaScript library that allows you to quickly generate charts with Observable Plot when working with DuckDB.

Disclaimer

This library is actively being developed, and does not fully support all Observable Plot features. However, we believe it's helpful for many common use cases and are actively adding feature support (see Contrubuting).

Documentation

See the documentation for more information.

Development

To locally develop DuckPlot, clone the repository and install the dependencies with npm install.

  • To view examples in the browser, run npm run dev and open http://localhost:8008/
  • To view examples in the server, run npm run dev-server and view the outputted .html files in examples/server-output
  • For an example creating multiple plots from a single data source, run npm run dev-multi-chart, and see the outputted files in examples/server-output

Examples can be easily added to the examples/ directory (and need to be exported by the examples/plots/index.js file) to test new features. For example, here is the line chart example:

import { renderPlot } from "../util/renderPlotClient.js";
// This code is both displayed in the browser and executed
const codeString = `// Standard line chart
duckplot
  .table("stocks")
  .x("Date")
  .y("Open")
  .color("Symbol")
  .mark("line")
`;

export const line = (options) => renderPlot("stocks.csv", codeString, options);

If you're actively developing DuckPlot, you can run npm run watch:build to watch for changes in the src/ directory and automatically recompile the TypeScript code.

Testing

Run npm run test to test

Implementation notes

Because DuckDB has different APIs for WASM and Node.js, DuckPlot uses a conditional import to load the appropriate DuckDB API based on the environment.

Performing axis adjustments on the server requires measuring the text width of the axis labels. This is done using opentype.js. You can pass in your own font for more precise measurements.

Contributing

Feel free to open a pull request or file an issue if you have any suggestions or would like to contribute to the project. We are actively working on adding more features and improving the library. However, we are a small team and are actively using this library in our production software, so we may not be able to merge all pull requests.

License

This project is licensed under the MIT License.