Package: wagtail-plotly
Wagtail PlotlyThis project aims to providecontent focusedmanagement ofPlotly.pycharts inWagtail CMSand to give developers and easy way customise and extend plots.Some more examplesInstallationInstall fromPyPI:pip install wagtail-plotlyThen add the following to your project'sINSTALLED_APPS.'wagtail.contrib.table_block',
'wagtail_plotly',
'wagtail_json_widget',SettingsWAGTAIL_PLOTLY_INCLUDE_PLOTLYJSDefault:'https://cdn.plot.ly/plotly-1.58.4.min.js'A url string providing the location of a Plotly JS libararyDEFAULT_PLOTLY_JSON_DIRECTORYDefault:'plotly'The name of theappdirectory in which to look for custom json plots. Wagtail Plotly will search all installed apps looking for a directory matching theDEFAULT_PLOTLY_JSON_DIRECTORYvalue and will attempt to load any.jsonfiles it contains.See Customisingfor more information.Usage overviewThere are several plot blocks that you can use out of the box:BarChartBlock / LinePlotBlockContourPlotBlock / HeatmapPlotBlockPieChartBlockScatterPlotBlockAdding one of these blocks provides you with input fields to manage the content of your plot, primarily titles and data, and a layout/style option(s). There is one default option out-of-the-box and more can be added by developers via.jsonfiles usingPlotly's schema.See CustomisingThis app also provides versions of the above blocks that support case by case customisation via a json field in the CMS UI.Example useOne way of using it is to create aStreamBlock:fromwagtail.coreimportblocksfromwagtail_plotly.blocksimport(BarChartBlock,ContourPlotBlock,HeatmapPlotBlock,LinePlotBlock,PieChartBlock,ScatterPlotBlock,)classMyStreamBlock(blocks.StreamBlock):bar_chart=BarChartBlock()contour_plot=ContourPlotBlock()heatmap_plot=HeatmapPlotBlock()line_plot=LinePlotBlock()pie_chart=PieChartBlock()scatter_plot=ScatterPlotBlock()Add theStreamBlockto aStreamFieldon a Wagtail page:fromwagtail.admin.edit_handlersimportStreamFieldPanelfromwagtail.core.fieldsimportStreamFieldfromwagtail.core.modelsimportPagefrom.blocksimportMyStreamBlockclassMyPage(Page):body=StreamField(MyStreamBlock(),null=True)content_panels=Page.content_panels+[StreamFieldPanel('body'),]Then in the page template:{% load static wagtailcore_tags %}

{% include_block page.body %}CustomisingConfiguringplotlygraphscanbe complex because there are a lot of options available.plotlyprovideChart Studiofrom which graphs and layouts can be made and exported as JSON data.Wagtail Plotly is designed to consume a subset of this data with minimal effort by developers:
Wagtail Plotly will look for directories namedplotly(by default) in each installed app and any.jsonfiles therein are assumed to be configuration options that are presented to users asGraph layoutoptions. In this way developers can provide managed plot configurations to end-users that override the default settings.For example:my_plot.jsonmight contain:{"layout":{"xaxis":{"gridcolor":"#dddddd","mirror":true},"yaxis":{"gridcolor":"#dddddd","mirror":true},"autosize":true,"colorway":["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"]}}Customising StreamField BlocksPlots in Wagtail Plotly are a set of Wagtail StreamField blocks that share a common baseBasePlotBlock. They can be used as is or extended to create custom plots or features of Plotly that aren't (yet) handled by default.All of the blocks have aplot_datafield for entering plot data (based onwagtail.contrib.table_block) andbuild_datamethod for extracting data from the table ready for plotting.Creating new plot blocksNew plot blocks can be created in the usual way: subclassing from eitherBasePlotBlockor one of the above blocks.