Articles on: Tutorials

How to hide charts conditionally

How to hide charts conditionally



Since Carbone v4.3.0, the drop formatter is available to delete charts and any element from a document. Be sure to request version 4 (or higher) of Carbone:
For the Cloud API: set the header "carbone-version":4
For the Cloud Studio: Click on the top-right "settings" icon > click on "version" > Select 4.X.X.

Learn more about :drop formatter on the documentation

For the following exemple, we want to drop a chart if a dataset is empty.
Include the Carbone tag {d.values:ifEM:drop(chart)} within a shape alternate text, title or description.
the d.values is a list of values to create a chart, coming from a JSON dataset
the :ifEM is a conditional formatter checking if the list is empty.
the :drop(chart) formatter is fired if the previous condition is true. The first argument chart is required to defined the element to drop.

Locations to insert tags for:
LibreOffice: Right click on the chart > properties > Option tab > Insert the drop expression {d.values:ifEM:drop(chart)} in the name, text alternative or description field
MS Word: Right click on the chart > click on "edit alt text" > insert the drop expression {d.values:ifEM:drop(chart)}


DOCX template edited with MS Word

Updated on: 09/09/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!