분류 Reactjs

react-dynamic-charts

컨텐츠 정보

  • 조회 287 (작성일 )

본문

동적 데이터를 기반으로 애니메이션 차트 시각화를 작성하기 위한 React 라이브러리.


React Dynamic Charts를 사용하면 멋진 애니메이션 동적 차트를 만들어 데이터를 시각화 할 수 있습니다.


동적 차트를 사용하는 가장 기본적인 예는 다음과 같습니다.


https://github.com/dsternlicht/react-dynamic-charts 

https://dsternlicht.github.io/react-dynamic-charts/


<DynamicBarChart
  data={this.state.data}
  // Timeout in ms between each iteration
  iterationTimeout={100}
/>

애니메이션이 시작되고 애니메이션이 종료 될 때 사용자 정의 콜백을 추가 할 수도 있습니다. 콘솔을 확인하여 작동하는지 확인하십시오.


<DynamicBarChart
  data={this.state.data}
  onRunStart={() => {
    console.log("Started!");
  }}
  onRunEnd={() => {
    console.log("Ended!");
  }}
/>



Demo 


설치 


npm install --save react-dynamic-charts


용법 


데모를 확인하여 작동하는지 확인하십시오.


import React, { Component } from 'react';

import { LiveBarChart } from 'react-dynamic-charts';
import 'react-dynamic-charts/dist/index.css'; // Don't forget to import the styles

class App extends Component {
  state = {
    data: [
      // ...
    ]
  };

  render () {
    return (
      <LiveBarChart
        data={this.state.data}
      />
    )
  }
}


Props 


PropertyTypeDefaultDescription
dataarray[]An array of objects that contain the data of the chart (see section below).
baselinenumbernullIf you want the chart to have a baseline, add its number here. Could be useful for charts that include negative values.
iterationTimeoutnumber200Number of milliseconds you want between iterations.
startAutomaticallybooleantrueWhether the visualization should start running automatically. Default is true.
startRunningTimeoutnumber0Number of milliseconds you want before running the visualization.
onRunStartfunctionnullA callback function that being called once the visualization starts.
onRunEndfunctionnullA callback function that being called once the visualization ends.
showTitlebooleantrueWhether you want to show each iteration's title.
barHeightnumber50The height (in pixels) of each bar item.
showStartButtonbooleanfalseShow a start button that triggers the animation.
startButtonTextstring'Start'The text that will appear in the start button.
mainWrapperStylesobject{}Styles object for the component's main wrapper.
chartWrapperStylesobject{}Styles object for the chart wrapper.
baselineStylesobject{}Styles object for the baseline element.
iterationTitleStylesobject{}Styles object for the title element.
labelStylesobject{}Styles object for the chart's labels.
startButtonStylesobject{}Styles object for the start button.