Hi! I’m building a Dash application and need to create a detailed pie chart that shows two levels of information. Have created an example in excel to illustrate my point - inner pie is top level summary, and then the outer pie shows the ‘composition’ of each of the inner segment (pls ignore the numbers / labels, they are made up!)
Current thought process for building this in dash is to create two donut graphs for the two levels of info, and then having the outer graph with a large ‘hole’ to line the two graphs up correctly, but i do not know how to place the graphs on top of each other. Can anyone help?
I’ve built it out within my app, but for some reason the sunburst diagram is not being displayed?
I’ve created a simple app to replicate my problem - if I run the below, the app shows an empty black screen with no graph. Any idea why?
Thanks
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
labels = ['Conquests', 'First Time Buyers', 'Loyalists', 'test1', 'test2']
parents = ['', '', '', 'Conquests', 'Loyalists']
values = [20,30,40,20,40]
colors = {
'background': '#000000',
'text': '#ffffff',
'graph_background':'#757474'
}
app = dash.Dash()
app.layout = html.Div(
[
dcc.Graph(id='sunburst',
figure=go.Figure(
data=[go.Sunburst(
labels= labels,
parents=parents,
values=values,
branchvalues='total'
)],
layout = go.Layout(
plot_bgcolor= colors["background"],
paper_bgcolor= colors["background"],
font={"color": "#fff"},
margin = go.layout.Margin(t=0, l=0, r=0, b=0)
)
))
])
if __name__ == '__main__':
app.run_server(debug=True)
Okay so i’ve managed to display the sunburst graph now by removing the ‘branchvalues’ attribute completely / changing it’s value to ‘remainder’…
Do you know what about the dataset could cause the lack of response?
Have played with and changed the labels, parents and values attributes extensively, and the only time I can produce a diagram when using branchvalues=‘total’ is by replicating the dataset provided in the https://plot.ly/python/v3/sunburst-charts/ example
Figured it out - when using branchvalues = total, there needs to be a parent that makes up the ‘centre’ of the sunburst diagram… so for the examples in the link above, it would be ‘Eve’. The diagram will not display if there isn’t this ‘grandparent’ label / value.