Search code examples
powerbidata-visualizationgraphvizpowerbi-desktopgraph-visualization

Rendering Graphviz in Power BI


I have anaconda installed on my laptop which I usually use to carry out data analysis. I am new to Power BI. Using Graphviz, I have the following image enter image description here

Using the Python Scripting in Power BI and the same code I use in anaconda, I have tried to show this in Power BI but I can't find a way around this.

Can anyone help with a solution or suggestion.

Thanks.


Solution

  • For someone who will be looking for a way to do this, I have found a way around it.

    After reading the Microsoft Power BI document on Creating Power BI visuals using Python in Power BI Desktop, it specified that Python visuals are shown as images. To show this as an image, I saved it first to my laptop, then used matplotlib's mpimg.imread function to read the image immediately and display it on Power Bi.

    filename = 'PowerBiGraphviz'
    
    ctrlflw = Z12.render(filename, view=False)
    img = mpimg.imread(ctrlflw)
    
    fig, ax = plt.subplots(figsize=(20,20))
    ax.imshow(img)
    ax.axis('off')
    plt.show()
    

    Note that the visual is also responsive to filtering. Depending on your python script, the visual can take some more seconds before they come up.

    The way I have been able to make it faster is to extract just the information I would need to draw my visual on Power BI and import it to Power BI in a separate table.

    If you know a faster way, that information will be appreciated.