Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sheshbabu/react-frappe-charts

Lightweight React Charts
https://github.com/sheshbabu/react-frappe-charts

chart-library charting-library frappe-charts react-charts react-component reactjs storybook

Last synced: 4 days ago
JSON representation

Lightweight React Charts

Awesome Lists containing this project

README

        

# React Frappe Charts

React wrapper for [Frappe Charts](https://frappe.io/charts) with TypeScript definitions and Storybook playground

[![Bundlephobia](https://flat.badgen.net/bundlephobia/minzip/[email protected])](https://bundlephobia.com/result?p=react-frappe-charts) [![Bundlephobia](https://flat.badgen.net/bundlephobia/min/[email protected])](https://bundlephobia.com/result?p=react-frappe-charts) [![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@master/badge/badge-storybook.svg)](https://react-frappe-charts.netlify.app)

## Installation

**React Frappe Charts requires React 16.8.0 or later.**

```shell
$ npm install --save frappe-charts react-frappe-charts
```

## Usage

```ts
import ReactFrappeChart from "react-frappe-charts";

export default function MyChart(props) {
return (

);
}
```

Updating the `data` prop would update the chart with new data.

### With Next.js

The underlying `frappe-charts` library should be transpiled to avoid module loading issues. Install [next-transpile-modules](https://github.com/martpie/next-transpile-modules) with your package manager and then use the following code snippet:

```js
/* next.config.js */
const withTM = require("next-transpile-modules")(["frappe-charts", "react-frappe-charts"]);
module.exports = withTM({
/* Optionally, specify additional settings here */
});
```

## Export Chart

In order to export a chart we need to forward a ref to invoke the `chart.export()` feature from Frappe Charts.

Example:

```ts
import React, { useRef } from "react";
import ReactFrappeChart from "react-frappe-charts";

export default function MyChart(props) {
const chartRef = useRef();

const exportChart = () => {
if (chartRef && chartRef.current) {
chartRef.current.export();
}
};

return (




Export


);
}
```

## Playground

Use [Storybook Playground](https://react-frappe-charts.netlify.com/?path=/story/playground--default) to tweak different props and see their effect on the chart rendered

## Contributing

PRs are welcome!