File size: 935 Bytes
8bb9bd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit as st
import plotly.graph_objects as go

import plotly.graph_objects as go

def create_sunburst_plot(labels, parents, values, ids, text):
    fig = go.Figure(go.Sunburst(
        labels=labels,
        parents=parents,
        values=values,
        ids=ids,
        text=text,
        hoverinfo="label+value",
        branchvalues="total",
    ))

    fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
    return fig

# Replace these lists with your own data
labels = ["Root", "Hip Surgery", "Knee Surgery", "CPT1", "CPT2", "CPT3", "CPT4"]
parents = ["", "Root", "Root", "Hip Surgery", "Hip Surgery", "Knee Surgery", "Knee Surgery"]
values = [None, 30, 40, 20, 10, 25, 15]
ids = ["Root", "Hip Surgery", "Knee Surgery", "CPT1", "CPT2", "CPT3", "CPT4"]
text = ["Root", "Hip Surgery", "Knee Surgery", "CPT1", "CPT2", "CPT3", "CPT4"]

fig = create_sunburst_plot(labels, parents, values, ids, text)
st.plotly_chart(fig)