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

@carbonplan/charts

v3.1.1

Published

themeable reusable responsive web charts

Downloads

457

Readme

carbonplan / charts

responsive reactive themeable charts

CI GitHub deployments NPM Version License: MIT

There are a lot of charting libraries for the web. Somehow, this one fills a niche that we think still exists. If nothing else, we find it useful, and will be using it ourselves! It's still super early in development, so expect lots of changes.

We're designing @carbonplan/charts with a few goals in mind:

  • built for modern react :arrow_upper_right:
  • fully responsive :left_right_arrow:
  • modular and composable :recycle:
  • easy to theme via theme-ui :sparkles:
  • plays great with MDX :tada:

It's also super light weight, depending only on react and theme-ui and some d3 utility packages. If there's interest we could probably factor out the theme-ui dependency so it's optional.

background

This package is most directly inspired by pancake, an experimental package build for svelte. The concept motivating pancake is that responsive charts that adapt fluidly to their containers without the need for redrawing can be built by carefully combining HTML for the chart and axes and SVG with viewBox for the graphical elements. It's like an SVG sandwich or pancake. Pick your favorite food metaphor. Rich Harris described the concept super clearly in a blog post. Without knowing about pancake, we started doing almost exactly the same thing a few months ago for our charts at CarbonPlan. There must be something to it.

However, to our knowledge, none of the existing charting libraries for JS help streamline this pattern. And pancake is built for svelte, whereas we're mainly using react. That's how we got here.

Also worth mentioning that we've used vega and vega-lite and d3 a lot. We love them, we're taking inspiration all over the place, and even using some d3 utilities under the hood. Incredibly grateful to the developers of those tools.

usage

Here's a super simple scatter chart just to give you the idea.

import {
  Chart,
  Grid,
  Ticks,
  TickLabels,
  AxisLabel,
  Plot,
  Scatter,
} from '@carbonplan/charts'

const ScatterChart = () => {
  return (
    <div style={{ width: '500px', height: '500px', padding: '64px' }}>
      <Chart x={[0, 100]} y={[0, 100]}>
        <Grid vertical horizontal />
        <Ticks left bottom />
        <TickLabels left bottom />
        <AxisLabel left>Variable one</AxisLabel>
        <AxisLabel bottom>Variable two</AxisLabel>
        <Plot>
          <Scatter
            data={[
              [10, 10],
              [50, 50],
              [90, 90],
            ]}
          />
        </Plot>
      </Chart>
    </div>
  )
}

This creates the following chart, shown with the light and dark themes of @carbonplan/theme.

Many more examples and documentation coming soon.

development

To update a component and publish a new version, first make your changes, then follow these steps

  • Increase the version number in package.json
  • npm run build
  • npm publish

license

All the code in this repository is MIT-licensed, but we request that you please provide attribution if reusing any of our digital content (graphics, logo, articles, etc.).

about us

CarbonPlan is a nonprofit organization that uses data and science for climate action. We aim to improve the transparency and scientific integrity of climate solutions with open data and tools. Find out more at carbonplan.org or get in touch by opening an issue or sending us an email.