Archi Forum

Archi Plug-ins => jArchi => Topic started by: Thomas Rohde on October 30, 2022, 13:04:41 PM

Title: Snippet: Charting framework for Archi
Post by: Thomas Rohde on October 30, 2022, 13:04:41 PM
This gist snippet is an attempt at creating a charting framework for Archi. Currently, it only supports three simple chart types, but can easily be expanded (to any chart supported by Plotly JS).

Download all files from this gist (https://gist.github.com/ThomasRohde/6382de4e0eda1a96ee229f90a871afc4), and place the chart specific files in __DIR__/lib. The primary charting script uses a lookup mechanism to load the appropriate code. Also, download the Plotly lib and place it in the __DIR__/lib directory (https://plotly.com/javascript/getting-started/).

Start charting by selecting a diagram-model-note in a view, then run the "Insert chart.ajs", which prompts for chart options and inserts a JSON string in a property of the selected diagram-model-note. Before ending, it calls the script "Refresh chart.ajs", which reads the JSON string and inserts the chart image in the note (using the dimensions of the note). When data in the model changes, you can refresh the chart by running "Refresh chart.ajs" again (with the note selected).

I was intending to use a canvas for charts, but I could not figure out how to set the image of a diagram-model-image.

I hope you find it useful, and even post your own chart scripts in the comments!