1.1.2 • Published 5 years ago

simply-chart v1.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

simply-chart

The simply-chart is a canvas chart lib without fancy style.It only create the chart with number tendency. It means the number from 0 to 100 and 0 to 1000 will be same in the simply-chart.

Installation

npm install --save simply-chart

Usage

import Chart from 'simply-chart';

const basicConifg = {
    base: {
        width: 200,
        height: 100,
        renderType: 'none',
        renderTime: 200 / 60,
        framePerSecond: 60,
    },
    attr: {
        lineWidth: 2,
    },
};

// line chart
const chart = new Chart.line({
    ...basicConifg,
    base: {
        dom: document.getElementById('test'),
        renderType: 'point',
    },
});
chart.update([1, 2.5, 3, 2.5, 1]).render();

Chart Support

The characteristics of simply-chart is simply, so it only support the simply chart syle now.

  • line line
  • bar bar

API

  • Chart.line(class Line)

    • constructor(conifg: IConfig)

    • methods:

      • update(data: number[]): Line update the data in chart.
      • render(): Line render chart.
    • Config:

      interface IConfig {
          base: BaseConfig;
          attr: LineConfig;
      }
  • Chart.bar

    • constructor(conifg: IConfig)

    • methods:

      • update(data: number[]): Line update the data in chart.
      • render(): Line render chart.
    • Config:

      interface IConfig {
          base: BaseConfig;
          attr: BarConfig;
      }
  • Config

    • BaseConfig

      keytypedefaultexplain
      domstring(dom selector) | HTMLElementcanvas init dom.
      width?nubmer200canvas width.
      height?number200canvas height.
      renderType?string(enums) 'none', 'total', 'point'nonecanvas animation type.none: no animationpoint: animation in point to pointtotal: animation in total line.
      renderTime?number2animation time.
      renderCurve?stringease-in-outcanvas animation bezier-curve. could be a string or point string. Etc: '.68,0 ,1, 1'.
      framePerSecond?number60canvas animation frame in 1 second.
    • LineConfig

      keytypedefaultexplain
      color?string'blue'line color
      lineWidth?number5line width
    • BarConfig

      keytypeDefaultexplain
      barWdith?numbercomputed width width and data number.each bar width.
      barRadius?number5border-radius at top.
      colors?string[]'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple'color for each bar,(The length must more than the data length)

1.1.2

5 years ago

1.1.1

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago