I am trying to render a UNIX directory structure via px.sunburst. The hoverdata over each sector should capture the size of whatever directory. Because of occasional repeated subdirectory names at various depths of hierarchy, I have to use the path variable instead of the labels/parents combination. (I tried labels/parents with unique ids, but it just didn’t work.) I am able to render the graph okay, but I need to set values of 0 for empty sectors because their current non-zero values end up skewing the aggregated totals for non-empty sectors. I tried this:-
fig = px.sunburst(data_frame=df_adc, path=path_result, values='cumulative_size', branchvalues='total', color='cumulative_size', color_continuous_scale=px.colors.diverging.Portland) marker_labels = list(fig.data['labels']) marker_values = list(fig.data['values']) new_marker_values = np.array([0 if label == 'None ' else value for label, value in zip(marker_labels, marker_values)], dtype=object) fig.data['values'] = new_marker_values fig.update_layout(margin=dict(l=0, r=0, b=0, t=10)) fig.show()
I now see that the new_marker_values array is exactly how it should be–each marker_labels label that is 'None ’ has a value of 0. But, in the end, the hoverdata does not show the values of 0 and aggregated totals are still off. What am I doing wrong here? How can I reliably update the values of only empty sectors so that branch totals can get computed correctly?