Thanks @AnnMarieW for your valuable time and aid with this project
Dash Chart Editor
Dash Chart Editor is a Dash component wrapper for the Plotly React Chart Editor package, enabling you to use an editor panel for Plotly charts in your Dash app.
Installation
pip install dash-chart-editor
Demo and Quickstart
import dash_chart_editor as dce
from dash import Dash, html
import plotly.express as px
app = Dash(__name__, external_scripts=["https://cdn.plot.ly/plotly-2.18.2.min.js"])
df = px.data.gapminder()
app.layout = html.Div([
html.H4("Dash Chart Editor Demo with the Plotly Gapminder dataset"),
dce.DashChartEditor(
dataSources=df.to_dict("list"),
)
])
if __name__ == "__main__":
app.run_server(debug=True)
Examples
See more demo apps in the /examples folder in GitHub.
import dash_chart_editor as dce
from dash import Dash, html
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
app = Dash(__name__, external_scripts=["https://cdn.plot.ly/plotly-2.18.2.min.js"])
app.layout = html.Div([
html.H4("Dash Chart Editor Demo with the Plotly Solar dataset"),
dce.DashChartEditor(dataSources=df.to_dict("list")),
])
if __name__ == "__main__":
app.run_server(debug=True)
Here is another app based on the pattern matching app in the Dash Example Index. It adds a dash-chart-editor for each figure:
Itβs amazing. Iβm just curious that can you add a function like every time the input information is changed, the code will appear at the bottom of the chart? So, users can look at it and can understand the settings of the chart more easily?
Originally, that was the case, the figure would update every time a setting would change. This however did not catch when you moved annotations 100%, plus becomes a bit heavy on larger datasets.
You can pass a True to saveState of the dce, and this will grab the current state of the figure and give you the figure output. This is currently the most consistent way to get the info.
You can then look at the raw figure output, or clean the data (this removes the long lists that are in the data sections) using cleanDataFromFigure. This will make the output a little more legible.
When i am running the sample code , i am getting below error message .
what can be the issue and how to resolve it . AttributeError: partially initialized module βdash_chart_editorβ has no attribute βDashChartEditorβ (most likely due to a circular import)
Absolutely fantastic tool, well done and thank you!
Is there any chance of adding an example of how to save state? For example in the React live demo app you can select pre-saved plot combinations and Iβm slightly struggling to see how to use saveState to do something similar.
It should ideally be like Mitosheet and generate the chart code, or the menu should be within a modal so it can be hidden.
Would be great if this came wrapped in something like dragula, so multiple charts could be inserted on a page and moved around (something like Dashboard engine)
Hard to configure the scales when it does not recognize a datatype (could be my user error)
1- You can recreate the chart using the built in functions and the figures that it creates. Storing a figure as a dictionary, then passing it to the chartToPython along with a df will update the data in the chart, which can be used as a figure in dcc.Graph.
2- Yes, but thatβs really not where this chart editor belongs. I am going to hook this up to my dashboard-helper, which does just that.
3- Yes, the data types is hard to determine on the JS side. Everything has to be determine by looking at the strings. There may be a way to determine this better.
This is very good, but if I want to know where to uniformly output the parameters after adjusting and changing the chart, because I want to apply the parameters to the Kanban chart developed by Dash
Very cool. I didnβt know there was a tool like this for react. I know the new one is for Dash, but I think itβll be real helpful to setup what you want with fewer trips back and forth to get it just right.
Edit β Is it possible to view the code for the chart thatβs generated? Question applies to both the new Dash, and prior React versions.