|
| 1 | +[](https://wuba.github.io/react-native-echarts/) |
| 2 | += |
| 3 | + |
| 4 | +[](https://www.npmjs.com/package/@wuba/react-native-echarts) |
| 5 | +[](https://www.npmjs.com/package/@wuba/react-native-echarts) |
| 6 | +[](https://codecov.io/gh/wuba/react-native-echarts) |
| 7 | +[](https://github.com/wuba/react-native-echarts/issues) |
| 8 | +[](https://github.com/wuba/react-native-echarts/graphs/contributors) |
| 9 | +[](https://github.com/wuba/react-native-echarts/pulls) |
| 10 | +[](https://github.com/wuba/react-native-echarts/blob/main/LICENSE) |
| 11 | + |
| 12 | +[简体中文](./README_CN.md) | [English](./README.md) | [日本語](./README_JP.md) |
| 13 | + |
| 14 | +[React Native](https://reactnative.dev/) バージョンの [Apache Echarts](https://github.com/apache/echarts)、[react-native-svg](https://github.com/software-mansion/react-native-svg) と [react-native-skia](https://github.com/shopify/react-native-skia) に基づいています。WebViewベースのソリューションと比較して、顕著なパフォーマンス向上を提供します。 |
| 15 | + |
| 16 | +[公式サイトで完全なドキュメントを確認できます](https://wuba.github.io/react-native-echarts/zh-Hans/)。 |
| 17 | + |
| 18 | +## 概要 |
| 19 | + |
| 20 | +* 🔥 Apache EChartsと同じ使い方 |
| 21 | +* 🎨 豊富なチャートサポート、ほぼすべての使用シーンをカバー |
| 22 | +* ✨ 選択可能なレンダリングライブラリ:[Skia](https://github.com/shopify/react-native-skia) または [SVG](https://github.com/software-mansion/react-native-svg) |
| 23 | +* 🚀 Webと再利用可能なコード |
| 24 | +* 📱 クリック、ドラッグ、ズームなどのジェスチャーサポート |
| 25 | + |
| 26 | +## インストール |
| 27 | + |
| 28 | +```sh |
| 29 | +yarn add @wuba/react-native-echarts echarts |
| 30 | +``` |
| 31 | + |
| 32 | +[react-native-svg](https://github.com/software-mansion/react-native-svg#installation) または [react-native-skia](https://shopify.github.io/react-native-skia/docs/getting-started/installation/) を必要に応じてインストールしてください。 |
| 33 | + |
| 34 | +> 最新バージョンの echarts、react-native-svg、および react-native-skia の使用をお勧めします |
| 35 | +
|
| 36 | +## 使用方法 |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +ほとんどのEChartsのチャートがサポートされており、使用方法は基本的に同じです。より多くの使用例やデモのプレビューについては、[Taro Playground](https://github.com/wuba/taro-playground) アプリケーションをダウンロードしてください。 |
| 41 | + |
| 42 | +### 例 |
| 43 | +```js |
| 44 | +// 好きなレンダラーを選択 |
| 45 | +// import { SkiaChart, SVGRenderer } from '@wuba/react-native-echarts'; |
| 46 | +import { SvgChart, SVGRenderer } from '@wuba/react-native-echarts'; |
| 47 | +import * as echarts from 'echarts/core'; |
| 48 | +import { useRef, useEffect } from 'react'; |
| 49 | +import { |
| 50 | + BarChart, |
| 51 | +} from 'echarts/charts'; |
| 52 | +import { |
| 53 | + TitleComponent, |
| 54 | + TooltipComponent, |
| 55 | + GridComponent, |
| 56 | +} from 'echarts/components'; |
| 57 | + |
| 58 | +// 拡張コンポーネントを登録 |
| 59 | +echarts.use([ |
| 60 | + TitleComponent, |
| 61 | + TooltipComponent, |
| 62 | + GridComponent, |
| 63 | + SVGRenderer, |
| 64 | + // ... |
| 65 | + BarChart, |
| 66 | +]) |
| 67 | + |
| 68 | +const E_HEIGHT = 250; |
| 69 | +const E_WIDTH = 300; |
| 70 | + |
| 71 | +// 初期化 |
| 72 | +function ChartComponent({ option }) { |
| 73 | + const chartRef = useRef<any>(null); |
| 74 | + |
| 75 | + useEffect(() => { |
| 76 | + let chart: any; |
| 77 | + if (chartRef.current) { |
| 78 | + // @ts-ignore |
| 79 | + chart = echarts.init(chartRef.current, 'light', { |
| 80 | + renderer: 'svg', |
| 81 | + width: E_WIDTH, |
| 82 | + height: E_HEIGHT, |
| 83 | + }); |
| 84 | + chart.setOption(option); |
| 85 | + } |
| 86 | + return () => chart?.dispose(); |
| 87 | + }, [option]); |
| 88 | + |
| 89 | + // 好きなチャートコンポーネントを選択 |
| 90 | + // return <SkiaChart ref={chartRef} />; |
| 91 | + return <SvgChart ref={chartRef} />; |
| 92 | +} |
| 93 | + |
| 94 | +// コンポーネントの使用 |
| 95 | +export default function App() { |
| 96 | + const option = { |
| 97 | + xAxis: { |
| 98 | + type: 'category', |
| 99 | + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], |
| 100 | + }, |
| 101 | + yAxis: { |
| 102 | + type: 'value', |
| 103 | + }, |
| 104 | + series: [ |
| 105 | + { |
| 106 | + data: [120, 200, 150, 80, 70, 110, 130], |
| 107 | + type: 'bar', |
| 108 | + }, |
| 109 | + ], |
| 110 | + } |
| 111 | + return <ChartComponent option={option} /> |
| 112 | +} |
| 113 | +``` |
| 114 | +
|
| 115 | +### SvgChart または SkiaChart のみを使用 |
| 116 | +```js |
| 117 | +import SvgChart, { SVGRenderer } from '@wuba/react-native-echarts/svgChart'; |
| 118 | +``` |
| 119 | +または |
| 120 | +```js |
| 121 | +import SkiaChart, { SkiaRenderer } from '@wuba/react-native-echarts/skiaChart'; |
| 122 | +``` |
| 123 | +
|
| 124 | +## 貢献 |
| 125 | +
|
| 126 | +リポジトリに貢献する方法や開発ワークフローについては、[貢献ガイド](CONTRIBUTING.md) を参照してください。 |
| 127 | +
|
| 128 | +## 貢献者 |
| 129 | +
|
| 130 | +このプロジェクトの存在は、貢献してくれたすべての人々のおかげです: |
| 131 | +
|
| 132 | +[](https://github.com/wuba/react-native-echarts/graphs/contributors) |
| 133 | +
|
| 134 | +## ライセンス |
| 135 | +
|
| 136 | +Apache-2.0 |
| 137 | +
|
| 138 | +--- |
| 139 | +
|
| 140 | +[create-react-native-library](https://github.com/callstack/react-native-builder-bob) を使用して作成されました。 |
0 commit comments