1.0.13 • Published 7 months ago

react-echarts-library v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

React ECharts Library

A modern React wrapper for Apache ECharts v5 with TypeScript support.

Installation

npm install react-echarts-library echarts
# or
yarn add react-echarts-library echarts

Basic Usage

import React from 'react';
import { EChartsReact } from 'react-echarts-library';

const SimpleChart = () => {
  const option = {
    title: {
      text: 'Basic Line Chart'
    },
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
      }
    ]
  };

  return <EChartsReact option={option} style={{ height: 400 }} />;
};

export default SimpleChart;

Props

PropTypeDefaultDescription
optionEChartOptionrequiredECharts option config
themestring or object-Theme to be applied
styleCSSProperties{ height: 300 }Container style
classNamestring''Container class name
autoResizebooleantrueEnable auto resize
onChartReadyFunction-Callback when chart is ready
onEventsObject{}Event handlers

Event Handling

const Chart = () => {
  const option = { /* chart options */ };
  
  const onEvents = {
    'click': (params, chart) => {
      console.log(params, chart);
    }
  };
  
  return <EChartsReact option={option} onEvents={onEvents} />;
};

Accessing the Chart Instance

You can access the echarts instance through the onChartReady callback:

const Chart = () => {
  const option = { /* chart options */ };
  
  const handleChartReady = (chart) => {
    // Do something with the chart instance
    chart.resize();
  };
  
  return <EChartsReact option={option} onChartReady={handleChartReady} />;
};

Examples

See the examples folder for more examples of various chart types and configurations.

License

MIT

1.0.13

7 months ago

1.0.12

7 months ago

1.0.10

7 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago