# chart-editor
**Repository Path**: yyljlyy/chart-editor
## Basic Information
- **Project Name**: chart-editor
- **Description**: 自定义图表工具
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2018-11-12
- **Last Updated**: 2024-11-22
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# react-chart-editor
> Customizable React-based editor panel for Plotly charts, Part of Plotly's [React Component Suite](https://plot.ly/products/react/) for building data visualization Web apps and products.
master

## Demo & Screenshots
Check out the [live demo here](https://plotly.github.io/react-chart-editor/).

## Quick start
Check out the demo of the latest release of the `DefaultEditor` at https://plotly.github.io/react-chart-editor/ or run it locally with:
```
git clone [this repo]
cd react-chart-editor
cd examples/demo
npm install
npm start
```
See more examples
[here](https://github.com/plotly/react-chart-editor/tree/master/examples).
## Overview
This module's entry point is a React component called `` which connects an instance of `` to a [plotly.js](https://plot.ly/javascript/)-powered `` component care of [`react-plotly.js`](https://github.com/plotly/react-plotly.js). `` accepts as children React components whose descendents are input elements wrapped via `connectToContainer()` calls so as to bind them to the ``'s figure's values. If no children are passed to the ``, the `` is used. This module also exposes the [building block components](#Built-in-Components) that comprise the `` so that developers can create their own customized editors.
## Styling the `` and the built-in components
* Import editor styles with `import 'react-chart-editor/lib/react-chart-editor.min.css'`
* Interested in [theming](https://github.com/plotly/react-chart-editor/tree/master/THEMING.md)?
* Need to support IE11? import the IE css instead: `import 'react-chart-editor/lib/react-chart-editor.ie.min.css'`
## Development Setup
This repo contains a [dev app](https://github.com/plotly/react-chart-editor/tree/master/dev) that depends on the components locally and is configured for hot reloading, for easy local development. A `jest`-based test suite is also included.
```
cp accessTokens.tpl.js accessTokens.js # and edit to taste
npm install
npm start
# hacking happens here
npm test
```
## Built-in Components
This module provides a number of nestable _containers_ which are intended to contain _fields_ that render _widgets_ that have been connected to individual values in the figure via _connector functions_. Containers can also be connected to parts of the figure tree (e.g. `layout` or specific traces in `data`) such that their child fields map to the appropriate leaf values. A field must have a connected container as an ancestor in order to be bound to the figure. The `` and connector functions use the React [`context` API](https://reactjs.org/docs/legacy-context.html) to push configuration information to child components.
At a pseudo-code level it looks like this:
```javascript
```
The [custom editor example](https://github.com/plotly/react-chart-editor/tree/master/examples/custom) shows how to build a custom editor, and shows off all of the general-purpose containers and fields listed below.
### General-purpose Containers
* ``: renders as a sidebar selector menu for ``s
* ``: renders as a generic rectangular container with special handling for collapsing/expanding child ``s and optionally an 'add' button for creating them, has special [visibility rules](https://github.com/plotly/react-chart-editor/tree/master/src/components/containers/__tests__/ConnectedContainersVisibility-test.js) that depend on plotly figure
* ``: collapsable container within a ``, has special [visibility rules](https://github.com/plotly/react-chart-editor/tree/master/src/components/containers/__tests__/ConnectedContainersVisibility-test.js) that depend on plotly figure
* ``: uncollapsable container within a `` or ``, has special [visibility rules](https://github.com/plotly/react-chart-editor/tree/master/src/components/containers/__tests__/ConnectedContainersVisibility-test.js) that depend on plotly figure
* ``, ``, ``: same as `PlotlyPanel`, `PlotlyFold`, `PlotlySection`, but there are no special visibility rules, those containers [always show, and always show their children](https://github.com/plotly/react-chart-editor/tree/master/src/components/containers/__tests__/UnconnectedContainersVisibility-test.js), but Fold does not have the canDelete functionality as its context related
* ``: wraps any item you would like to see appear in the sidebar menu.
### General-purpose Fields
All Fields except `` accept an `attr` property to bind them to a key in the figure (see https://plot.ly/javascript/reference/ for exhaustive documentation of figure keys). This property can be a `.`-delimited path to a leaf, starting at the context-appropriate point in the figure for the parent container (see connector functions below).
* ``: renders its children as HTML, useful for displaying help text
* ``: renders as a text field with arrows and units, useful for numeric values
* ``: renders as a button group, useful for mutually-exclusive low-cardinality enumerable values
* ``: renders as a dropdown menu useful for mutually-exclusive high-cardinality enumerable values
* ``: renders a dropzone component to drag and drop files to load
* ``: renders as a popup color-picker, useful for CSS color hex value strings
* ``: npm module [react-colorscales](https://github.com/plotly/react-colorscales)
* ``: renders as a list of checkboxes, useful for `+`-joined flag lists like `data[].mode`
* ``: renders as a WYSIWYG editor, useful for text like `layout.title`, takes props: `latexOnly`, `richTextOnly`, `htmlOnly` if no format props given, defaults to the `MultiFormat` text editor (latex && richText && html)