GithubHelp home page GithubHelp logo

deku-chart's Introduction

deku-chart

NPM version license

A chart component built with Deku and Chart.js.

Installation

$ npm install deku-chart

Usage

<Chart type="Bar">
  {
    {
      January:  [65, 28],
      February: [59, 48],
      March:    [80, 40],
      April:    [81, 19],
      May:      [56, 86],
      June:     [55, 27],
      July:     [40, 90]
    }
  }
</Chart>

License

MIT

deku-chart's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

sessa

deku-chart's Issues

Multiple Chart instances

I tried to do something similar to this library earlier but ended up with the issue that every time the component is rendered again it creates a new chart instance without destroying the old on first.

From the look of it, your code has this problem as well.

The way I solved it was by creating a chartManager:

function createChartManager() {
  let chart;
  return (ctx, type, info) => {
    if(chart) {
      chart.destroy();
      chart = null;
    }
    chart = new Chart(ctx)[type](info);
  };
}

Then create a new chart manager for the component when it's initialized (I used the initialState function) and just call state.chart(ctx, type, info) whenever you need to update the chart.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.