Hi! I hope everyone is well here :)
I wanted to share this little protocol I did with my friend (& colleague) @TH. It's a little reporting protocol generating 3 simple charts, BUT in 3 different ways! AND in simple but reusable components. What's not to like!
It's not about the chart here, it's about having a quick starting point, for you to learn how to reuse some snippets of R or Python code, and use them both in a single protocol.
The protocol looks like this:
The magic behind:
- Each script generates one chart
- R Scripts generate an image
- Python scripts generate a base64 string of an image & then PilotScript ConvertFromBase64() converts it into an image
- Image from Data component creates a Reporting element from the image
- Any Report Viewer will do :)
- Bathe in glory
They are also componentized, so you can learn how to add a few parameters to your component, so that your friends don't have to go in your R or Python code.
Histogram (Jupyter) | Line Chart (Python) | R | |
|---|---|---|---|
| Script component | Python Jupyter Notebook (on Server) | Python (on Server) | R Custom Script |
| Before the component | - | Merge All Data | - |
| Color parameter mapping | import ppdataloader color = plp_globals.get('Color') | import pilotpython context= pilotpython.Context(ctxt) props= context.getComponentParameters(); color= props.get("Color").getValue().getString() | \\\$(Color) |
| Output Port | Pass Port | Pass Port | Fail Port |
| PilotScript after the Component | ConvertFromBase64(Histogram) | ConvertFromBase64(Plot) | - |
And yes it works, see the output:
I told you, it was not about the chart 😉
Here is the protocol together with the 3 components:
Enjoy
