Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Sunburst Chart and values - ValueError: All arguments should have the same length. The length of argument `values` is 360, whereas the length of previously-processed arguments ['risk_types'] is 1145

$
0
0

I am trying to get a sunburst chart to show the actual unique values for an item and not just the count.
In my live data I have a data frame I have made from an excel spreadsheet. This dataframe has 1145 rows. These rows are made from exploding the merged cells in an excel spreadsheet. In its unexploded form I have 360 unique 'risk_id’s but when I plot it, it shows 1145 in the center.

How do I get it to show the unique values. The center should show a total of 360 when filtering correctly

I have the following but it throws a value error telling me - “ValueError: All arguments should have the same length. The length of argument values is 360, whereas the length of previously-processed arguments [‘risk_types’] is 1145”

# Create a dataframe for us to use
sunburst_df = raca_df[['risk_types', 'risk', 'level3', 'risk_id']]
a = 'Group'
sunburst_df['company'] =a


c = sunburst_df['risk_id'].unique()
# now build out our chart
fig = px.sunburst(
    data_frame=sunburst_df,
    path=['company','risk_types','risk','level3'],
    color_continuous_scale=px.colors.sequential.BuGn,
    maxdepth=2,
    values=c,
    #branchvalues='total', # other option is 'remainder'
    hover_name='risk_types',
    title='Breakdown of Risk to Group by Risk Type',
    template='presentation'
)

fig.update_layout(title_x=0.5, height = 900, uniformtext=dict(minsize=10))
fig.update_traces(textinfo='label+percent parent+value', insidetextorientation='radial')
fig.show()

If I go with the basic example using m,y data it fills out ok just the count under group is wrong

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles