# @twp0217/react-echarts-core

> Apache ECharts component for React

Latest version **5.2.3** (published 2022-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @twp0217/react-echarts-core
pnpm add @twp0217/react-echarts-core
yarn add @twp0217/react-echarts-core
bun add @twp0217/react-echarts-core
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.2.3 |
| Published | 2022-08-03 |
| First published | 2021-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 39.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | twp0217 |
| Maintainers | twp0217 |
| Keywords | react, echarts, react-component, react-echarts |

## Links

- npm: https://www.npmjs.com/package/@twp0217/react-echarts-core
- Repository: https://github.com/twp0217/react-echarts
- Homepage: https://github.com/twp0217/react-echarts#readme
- Issues: https://github.com/twp0217/react-echarts/issues
- npm.io page: https://npm.io/package/@twp0217/react-echarts-core

## Dependencies (2)

- [classnames](https://npm.io/package/classnames.md) ^2.3.1
- [@juggle/resize-observer](https://npm.io/package/@juggle/resize-observer.md) ^3.3.1

## 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

- 5.2.3 (latest) — 2022-08-03
- 5.2.2 — 2021-11-03
- 5.2.1 — 2021-10-28
- 5.2.0 — 2021-10-27
- 5.1.1 — 2021-09-29
- 5.1.0 — 2021-09-27

## README

# react-echarts-core

> **按需引入 ECharts 图表和组件**

Apache ECharts component for React（基于 React 的 Apache ECharts 组件）

## 安装

```bash
npm install echarts @twp0217/react-echarts-core --save
```

## 使用

```typescript
import React from 'react';
import EChartsCore, { EChartsOption } from '@twp0217/react-echarts-core';
// 引入 echarts 核心模块，核心模块提供了 echarts 使用必须要的接口。
import * as echarts from 'echarts/core';
// 引入柱状图图表，图表后缀都为 Chart
import { BarChart } from 'echarts/charts';
// 引入提示框，标题，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent,
  TransformComponent,
} from 'echarts/components';
// 标签自动布局，全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features';
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers';

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent,
  TransformComponent,
  BarChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
]);

export default () => {
  const option: EChartsOption = {
    title: {
      text: 'ECharts 入门示例',
    },
    tooltip: {},
    legend: {
      data: ['销量'],
    },
    xAxis: {
      data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'],
    },
    yAxis: {},
    series: [
      {
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20],
      },
    ],
  };

  return <EChartsCore option={option} echarts={echarts} />;
};
```

## API

### EChartsCoreProps

| 名称          | 说明                                                                                               | 类型                                          | 默认值  |
| ------------- | -------------------------------------------------------------------------------------------------- | --------------------------------------------- | ------- |
| echarts       | echarts 模块                                                                                       | ECharts                                       | -       |
| className     | 类名                                                                                               | string                                        | -       |
| style         | 样式                                                                                               | React.CSSProperties                           | -       |
| option        | 图表的配置项和数据                                                                                 | EChartsCoreOption                             | -       |
| theme         | [应用的主题](https://echarts.apache.org/zh/api.html#echarts.init)                                  | EChartsTheme                                  | -       |
| initOpts      | [初始化附加参数](https://echarts.apache.org/zh/api.html#echarts.init)                              | EChartsInitOpts                               | -       |
| setOptionOpts | [设置图表的配置项和数据附加参数](https://echarts.apache.org/zh/api.html#echartsInstance.setOption) | EChartsSetOptionOpts                          | -       |
| autoResize    | 自适应图表                                                                                         | boolean                                       | `false` |
| loading       | 是否显示加载动画                                                                                   | boolean                                       | -       |
| loadingConfig | [加载动画配置](https://echarts.apache.org/zh/api.html#echartsInstance.showLoading)                 | EChartsLoadingConfig                          | -       |
| onChartInit   | 图表初始化时的回调                                                                                 | (echartsInstance: EchartsInstance) => void    | -       |
| onEvents      | [图表事件](https://echarts.apache.org/zh/api.html#events)                                          | { [eventName: string]: (event: any) => void } | -       |

## 支持

- 如果项目对你有帮助，请点颗星星:star:，谢谢。
- 如果你对项目有想法、问题、BUG，欢迎讨论。

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