0.7.3 • Published 10 months ago

@aodin/charts v0.7.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Charts

Modular D3.js charts. View a live demo at https://aodin.github.io/charts/.

Install with:

npm i @aodin/charts

Chart are designed as extensible classes with basic defaults. Extend the existing classes to alter behaviors.

import * as d3 from "d3";
import { LineChart } from "@aodin/charts";

export class Example extends LineChart {
  // For example, to create a LineChart with its y-axis on the right...
  yAxis(g, y) {
    g.call(d3.axisRight(y));
  }
}

There are also pre-built files in /dist/. These charts expect an array of objects as the data parameter, e.g. [{x, y, z}...], but a different parser can be specified as the second argument of the constructor.

const data = [
  ["2020-01-01", 100, "A"],
  ["2020-02-01", 110, "A"],
  ["2020-03-01", 120, "A"],
  ["2020-04-01", 125, "A"],
  ["2020-05-01", 115, "A"],
  ["2020-06-01", 110, "A"],
];

export function parseArray(d) {
  return {
    x: d3.isoParse(d[0]),
    y: d[1],
    z: d[2],
  };
}

// If provided an SVG, it will attempt to use that element's width and height.
// Otherwise, an SVG element will be created underneath the provided selector.
charts.TimeSeries(data, parseArray).render("#element");

See examples for example line, area, bar, pie, and OHLCV candlestick charts.

Development

Test with: npm test

Build dist files with: npm run dist

Happy hacking!

aodin, 2024

0.7.3

10 months ago

0.7.2

10 months ago

0.7.1

10 months ago

0.7.0

10 months ago

0.5.8

12 months ago

0.5.7

12 months ago

0.5.9

12 months ago

0.6.3

11 months ago

0.6.2

11 months ago

0.6.1

12 months ago

0.6.0

12 months ago

0.5.6

12 months ago

0.5.5

12 months ago

0.5.4

12 months ago

0.5.3

12 months ago

0.5.2

12 months ago

0.5.1

12 months ago

0.5.0

12 months ago

0.4.6

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago