Package: dash-extendable-graph
dash-extendable-graphdash-extendable-graphis a Dash component library containing a single component:ExtendableGraph. The component was forked from Plotly's coreGraphcomponent (dash-core-components).dash-extendable-graphhas modifiedextendDataandprependDataproperties that accept trace data matching the format forfigure["data"]. These properties support (1) adding new traces and (2) allow multiple trace types to be extended/prepended within a single callback (not supported by the core component)Note: As of version 1.1.0,dash-extendable-graphincludes a minimized plotly.js as an internal dependency. Previously, the component assumed it would be used in conjunction withdash-core-components.InstallationGet started with:Install Dash and dependencies:https://dash.plot.ly/installation$pipinstall-rrequirements.txtInstall dash-extendable-graph$pipinstalldash-extendable-graphRunpython usage.pyVisithttp://localhost:8050in your web browserUsageGeneral examples may be found inusage.pyextendDataupdateData[list]: a list of dictionaries, each dictionary representing trace data in a format matchingfigure['data'](e.gdict(x=[1], y=[1]))traceIndices[list, optional]: identify the traces that should be extended. If the specified trace index does not exist, a (new) corresponding trace shall be appended to the figure.maxPoints[number, optional]: define the maximum number of points to plot in the figure (per trace).Based on thePlotly.extendTraces()api. However, theupdateDatakey has been modified to better match the contents ofPlotly.plot()(e.g.Graph.figure). Aside from following dash-familiar styling, this component allows the user to extend traces of different types in a single call (Plotly.extendTraces()takes a map of key:val and assumes all traces will share the same data keys).prependDataupdateData[list]: a list of dictionaries, each dictionary representing trace data in a format matchingfigure['data'](e.gdict(x=[1], y=[1]))traceIndices[list, optional]: identify the traces that should be extended. If the specified trace index does not exist, a (new) corresponding trace shall be appended to the figure.maxPoints[number, optional]: define the maximum number of points to plot in the figure (per trace).Based on thePlotly.prependTraces()api. However, theupdateDatakey has been modified to better match the contents ofPlotly.plot()(e.g.Graph.figure). Aside from following dash-familiar styling, this component allows the user to prepend traces of different types in a single call (Plotly.prependTraces()takes a map of key:val and assumes all traces will share the same data keys).CodeExtend a trace once per second, limited to 100 maximum points.importdash_extendable_graphasdegimportdashfromdash.dependenciesimportInput,Output,Stateimportdash_html_componentsashtmlimportdash_core_componentsasdccimportrandomapp=dash.Dash(__name__)app.scripts.config.serve_locally=Trueapp.css.config.serve_locally=Trueapp.layout=html.Div([deg.ExtendableGraph(id='extendablegraph_example',figure=dict(data=[{'x':[0],'y':[0],'mode':'lines+markers'}],)),dcc.Interval(id='interval_extendablegraph_update',interval=1000,n_intervals=0,max_intervals=-1),html.Div(id='output')])@app.callback(Output('extendablegraph_example','extendData'),[Input('interval_extendablegraph_update','n_intervals')],[State('extendablegraph_example','figure')])defupdate_extendData(n_intervals,existing):x_new=existing['data'][0]['x'][-1]+1y_new=random.random()return[dict(x=[x_new],y=[y_new])],[0],100if__name__=='__main__':app.run_server(debug=True)ContributingSeeCONTRIBUTING.mdLocal InstallationDependencies$npminstall
$virtualenvvenv
$.venv/bin/activate
$pipinstall-rrequirements.txtFor developers:$ pip install -r tests/requirements.txtBuild$npmrunbuildCheck out the component via component-playground$npmrunstartThe demo app is in `src/demo`Check out the sample Dash application using the component$pythonsetup.pyinstall
$pythonusage.pyTestsRun locallyRun linting + integration tests in one command:$npmruntestOr run tests individually:Code styleUsesflake8,eslint, andprettier. Checkpackage.json,.eslintrc,.eslintignorefor configuration settings.$npmrunlintAlso you can apply formatting settings.$npmrunformatIntegration TestsIntegration tests for the component can be found intests/$pytestSelenium test runner configuration options are located inpytest.ini(e.g.--webdriver,--headless). Seedash[testing]documentation for more information on built-ins provided by the dash test fixture.Run individual integration tests based on the filename.$pytesttests/test_extend_maxpoints.pyContinuous IntegrationThis repository uses a github action to automate integration testing. Linting and Tests are triggered for each pull request created in themasterbranch.Package PublishingThis repository uses a github action to automate package deployment (in this case, compiling a source archive and binary wheel usingsetuptools). Publishing is triggered on each published release.