Giter Site home page Giter Site logo

Can it support animation about react-chartist HOT 5 OPEN

fraserxu avatar fraserxu commented on July 20, 2024
Can it support animation

from react-chartist.

Comments (5)

larrybotha avatar larrybotha commented on July 20, 2024 3

Because you're relying on the Chartist library directly, importing it will by default import it twice into your compiled js if you're using Webpack.

Make sure to alias chartist so that Webpack resolves React-Chartist's Chartist and your Chartist:

// webpack.config.js
...
  resolve: {
    alias: {
      ...
      chartist: path.resolve(__dirname, 'node_modules/chartist'),
      ...
    },
  },
...

from react-chartist.

ellenschwartau avatar ellenschwartau commented on July 20, 2024 2

I animated bars by setting this as listener:

<ChartistGraph  ... listener={{"draw" : function(data) { if(data.type === 'bar') {
                data.element.animate({
                  y2: {
                      begin: 0,
                      dur: 500,
                      from: data.y1,
                      to: data.y2,
                      easing: Chartist.Svg.Easing.easeOutSine,
                  }});
}}}/>

from react-chartist.

TonyFrancis avatar TonyFrancis commented on July 20, 2024 1

yes
Give a new props to it listener

   <ChartistGraph key="1" className="ct-chart-line" data={{  labels: ["foo","bar"], series:[ [1,2,3],[3,4,5]]  }}  type={'Line'} listener={{"draw" : function(data) {
  if(data.type === 'line' || data.type === 'area') {
    data.element.animate({
      d: {
        begin: 2000 * data.index,
        dur: 2000,
        from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
        to: data.path.clone().stringify(),
        easing: Chartist.Svg.Easing.easeOutQuint
      }
    });
  } } }}/>

from react-chartist.

raptoria avatar raptoria commented on July 20, 2024

How do I make the bars animate it if I am passing new data to the chart via props every time a button is clicked? (not triggering the 'draw' function)

eg. in parent component I have:

import HBar from '../components/Chart/HorizontalChart';

      <HBar data={this.state.votes} /> 

HorizontalChart.jsx

      import React, {Component} from 'react';
      import ReactDOM from 'react-dom';
      import ChartistGraph from 'react-chartist';
      import styles from 'style!./chartist.css';

      export default class HorizontalChart extends Component {

        static propTypes = {
          data: React.PropTypes.object,
        }

        render() {

          let { data } = this.props;
          let options = {
            seriesBarDistance: 10,
            reverseData: true,
            high:20,
            low:0,
            horizontalBars: true,
            axisY: {
              offset: 70
            }
          };
          let type = 'Bar'

          return (
            <div> 
            <ChartistGraph data={data} options={options} type={type} />
            </div>
          )
        }
      }

from react-chartist.

lim1017 avatar lim1017 commented on July 20, 2024

Does anyone have a pie chart animation?
Ive looked over the above posts, but I really have no idea how animations works

from react-chartist.

Related Issues (20)

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.