0
  1. I have below scripts with python
import pandas as pd
import chart_studio.plotly as py
import plotly.graph_objects as go
labelListTemp1 = list(set(dataset.source.values))
labelListTemp2 = list(set(dataset.target.values))
labelList = labelListTemp1 + labelListTemp2
sankey_node = list(dict.fromkeys(labelList))
fig = go.Figure(data=[go.Sankey( node = dict( pad=15, 
                                             thickness=20, 
                                             line = dict(color = "black", width = 0.5),
                                             label = labelList,
                                             color = "blue" ),
                                              link = dict(source = dataset.source.apply(lambda x: labelList.index(x)),
                                                          target = dataset.target.apply(lambda x: labelList.index(x)),
                                                          value = dataset.value))])

fig.show()
  1. Then I enable python visual in powerBI, and then drag-and-drop source, target and value into 'Values' section.

  2. Then I run the python script in step1

  3. But the sankey chart doesn't displayed in powerBI. the code open a browser and display the sankey chart in the browser, which is not what I want. please refer to below screenshot.

[![enter image description here][1]][1]

Expected result: I want the sankey chart displayed inside powerBI, so I can publish the chart and send it to team members.

Any expert please help take a look what's wrong with my code?

Thanks, Cherie

peace
  • 299
  • 2
  • 16

1 Answers1

0

i find an anwser from a post with "import plotly.io as pio" first, and then replace fig.show() with below code

pio.write_image(fig, 'perfUXRGoal.png').

with above code, it's a static image displayed inside powerBI, instead of interactive html chart.

peace
  • 299
  • 2
  • 16