0.3.0 • Published 9 months ago

@lg-charts/core v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

Core Chart Components

Library of composable charting components that provides a way to create interactive charts rendered on canvas.

npm (scoped)

Installation

Yarn

yarn add @lg-charts/core

NPM

npm install @lg-charts/core

Basic Example

import { Chart, Line, Grid, XAxis, YAxis } from '@lg-charts/core';

<Chart>
  <Grid vertical={false}>
  <XAxis type="time" />
  <YAxis type="value" unit="GB" />
  <Line
    name="Series 1"
    data={[
      [new Date(2020, 01, 01), 0],
      [new Date(2020, 01, 02), 1],
      [new Date(2020, 01, 03), 2],
      [new Date(2020, 01, 04), 3],
      [new Date(2020, 01, 05), 4],
    ]}
  />
  <Line
    name="Series 2"
    data={[
      [new Date(2020, 01, 01), 4],
      [new Date(2020, 01, 02), 3],
      [new Date(2020, 01, 03), 2],
      [new Date(2020, 01, 04), 1],
      [new Date(2020, 01, 05), 0],
    ]}
  />
</Chart>;

Parent Components

Chart

Chart container component.

Props

NameDescriptionTypeDefault
onChartReadyCallback to be called when chart is finished rendering.() => void

Child Components

Line

Component that takes in data points and renders a single line on the chart.

Props

NameDescriptionTypeDefault
nameName used to identify the series.string
dataData array of tuples that represent x and y coordinates in the series.Array<string | number | Date, string | number | Date>

Grid

Component that displays grid lines on the chart.

Props

NameDescriptionTypeDefault
horizontalShow horizontal grid lines.booleantrue
verticalShow vertical grid lines.booleantrue

XAxis

Renders an x-axis.

Props

NameDescriptionTypeDefault
typeType of axis.'category' | 'value' | 'time' | 'log'
label (optional)Label name to be rendered on the axis.string
unit (optional)String that will be appended to the values of the axis. Only applies if type of value. Note: this unit will not impact the data. E.g. if data is given in MB and the units are set to "GB", the component won’t convert these values. Conversion of data is up to the consumer.string

YAxis

Renders a y-axis.

Props

NameDescriptionTypeDefault
typeType of axis.'category' | 'value' | 'time' | 'log'
label (optional)Label name to be rendered on the axis.string
unit (optional)String that will be appended to the values of the axis. Only applies if type of value. Note: this unit will not impact the data. E.g. if data is given in MB and the units are set to "GB", the component won’t convert these values. Conversion of data is up to the consumer.string