# echarts-rc

> Apache Echarts component for React.

Latest version **0.0.9** (published 2023-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install echarts-rc
pnpm add echarts-rc
yarn add echarts-rc
bun add echarts-rc
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2023-08-11 |
| First published | 2023-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alexanderpo |
| Maintainers | alexanderpo |
| Keywords | echarts, react, component, wrapper, resize |

## Links

- npm: https://www.npmjs.com/package/echarts-rc
- Repository: https://github.com/Apozhidaev/echarts-rc
- Homepage: https://github.com/Apozhidaev/echarts-rc#readme
- Issues: https://github.com/Apozhidaev/echarts-rc/issues
- npm.io page: https://npm.io/package/echarts-rc

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.9 (latest) — 2023-08-11
- 0.0.8 — 2023-08-10
- 0.0.7 — 2023-08-06
- 0.0.6 — 2023-08-02
- 0.0.5 — 2023-07-24

## README

# echarts-rc

The React wrapper for [Apache ECharts](https://github.com/apache/incubator-echarts).

### Purpose

Why we have one more wrapper for echarts?

1. Use of the [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) to auto resize.
2. Full access to all echarts features.
3. Use of modern react.


### Attributes

* **option** - the echarts option config, can see [https://echarts.apache.org/option.html](https://echarts.apache.org/option.html).
* **opts** - merge option setup (`opts` parameter of `setOption` function) [https://echarts.apache.org/en/api.html#echartsInstance.setOption](https://echarts.apache.org/en/api.html#echartsInstance.setOption)
* **theme** - theme to be applied. [https://echarts.apache.org/en/api.html#echarts.init](https://echarts.apache.org/en/api.html#echarts.init).
* **initOpts** - init options (`opts` parameter of `init` function) [https://echarts.apache.org/en/api.html#echarts.init](https://echarts.apache.org/en/api.html#echarts.init)
* **onInit** - when the chart is init, will callback the function with the `echartsInstance` as it's paramter.
* **onUpdate** - will callback after `setOption`.
* **onResize** - will callback after `resize`.
* **...htmlProps[]** - html attributes (className, styles, ...)


### How to Use

Step 1.
```bash
npm i echarts-rc

# `echarts` is the peerDependence of `echarts-rc`, you can install echarts with your own version.
npm i echarts
```

Step 2.
```jsx
import { useMemo } from "react";
import EChartsComponent, { EChartsOption } from "echarts-rc";

function App() {
  const options: EChartsOption = useMemo(
    () => ({
      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 (
    <EChartsComponent
      option={options}
      opts={{ notMerge: true }}
      style={{ height: 500 }}
      onInit={(instance) => {
        instance.on("click", (e) => {
          console.log(e);
        });
      }}
    />
  );
}

export default App;
```

---
_Source: https://npm.io/package/echarts-rc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
