1.0.13 • Published 5 months ago

react-echarts-library v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
5 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

5 months ago

1.0.12

5 months ago

1.0.10

5 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago