Exporting Graphes - Chart wrapper object and 3rd party

Hello community, I’m new here and my knowledge of Python is limited so please bear with me :sweat_smile: I’m using versions; pyRevit 4.8, Ironpython 2.7.7, and Cpython 3.8.5.

I aim to manipulate data, produce graphs, and then export possibly as an image/pdf. I have tried two ways, the first “Normal” approach is with builtin ‘PyRevitOutputChart’ and the other with Cpython using 3rd party packages but in both of them I have stumbled on some problems :

  1. pyRevit Graphe: I was able to output the chart within the output window but I can’t find a way to export it. When exporting the window as html the graph was not in it. Seeing the documentation Visualizing Data. I’m not sure where/how i should be inserting commands in Python to export Chart.js like shown by QuickCharts How to download and export Chart.js images (if it is even possible).

  2. With Cpython : My first approach was with Matplotlib but I encountered the same problem as here where the pyparsing from pyRevit was being caught. I ‘forced’ the import from the correct one in my python 3.8 using importlib.util explained here but it gave this error :

CPython Traceback:
ImportError : cannot import name '_api' from 'pyparsing' (C:\Users\Valqu\AppData\Local\Programs\Python\Python38\Lib\site-packages\pyparsing\__init__.py)
 File "C:\Users\Valqu\PycharmProjects\ExcelTools.extension\RevitAPIs.tab\2Test.panel\V2-Graph.pushbutton\script.py", line 37, in <module>
spec2.loader.exec_module(matplotlib)
 File "<frozen importlib._bootstrap_external>", line 783, in exec_module
 File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
 File "C:\Users\Valqu\AppData\Local\Programs\Python\Python38\Lib\site-packages\matplotlib\__init__.py", line 161, in <module>
 from . import _api, _version, cbook, _docstring, rcsetup

pyRevitLabs.PythonNet
at Python.Runtime.Runtime.CheckExceptionOccurred()
 at Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr _locals)
 at Python.Runtime.PyScope.Exec(String code, PyDict locals)
 at PyRevitLabs.PyRevit.Runtime.CPythonEngine.Execute(ScriptRuntime& runtime)

From what I searched, it is a double-dependency problem. I tried to understand this post Getting d3.js to work within pyRevit on the forum but honestly, it is way off my league. Then I tried using bokeh and Pygal but both of them when importing gave me identic errors:

CPython Traceback:
AttributeError : 'WindowsPath' object has no attribute 'read_text'
 File "C:\Users\Valqu\PycharmProjects\ExcelTools.extension\RevitAPIs.tab\2Test.panel\V2-Graph.pushbutton\script.py", line 26, in <module>
from bokeh.plotting import figure, show #Graphe
 File "C:\Users\Valqu\AppData\Local\Programs\Python\Python38\Lib\site-packages\bokeh\__init__.py", line 56, in <module>
 __version__ = importlib_metadata.version("bokeh")
 File "importlib\metadata.py", line 531, in version
 File "importlib\metadata.py", line 236, in version
 File "importlib\metadata.py", line 224, in metadata
 File "importlib\metadata.py", line 491, in read_text

pyRevitLabs.PythonNet
at Python.Runtime.Runtime.CheckExceptionOccurred()
 at Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr _locals)
 at Python.Runtime.PyScope.Exec(String code, PyDict locals)
 at PyRevitLabs.PyRevit.Runtime.CPythonEngine.Execute(ScriptRuntime& runtime)

What should be my approach to make this work ? Thanks in advance for this amazing tool that I have already done so much :smile: