Modifying Report Chart Data

I am trying to use the following script to modify my Report chart data but it doesn’t appear to do anything. Any thoughts?

chartData = event.source.parent.getComponent(‘CategoryChart’).data

ColumnCount = [1,2]

filteredData = system.dataset.filterColumns(chartData, ColumnCount)
event.source.parent.getComponent(‘CategoryChart’).data = filteredData

Where is this code? The syntax suggests a Vision component, but your title says a chart in a Report. Please elaborate.

In the script of a Category Chart on a Report. If I am using the wrong syntax. Is there a way to do what I am looking to do? If so, how?

Hi @ryoungk, just to be clear, are you referring to Report charts which are part of the reporting module, or Vision charts

As @pturmel suggested, the script syntax suggests Vision.

Could you post any screenshots or code snippets so we can get a better understanding of what is going on? :slight_smile:

Yes in a report chart. Pardon the marks, I am trying to avoid sharing IP.

Thank you :smiley: just wanted to make sure we’re all on the same page

That’s absolutely fine, I think there’s enough to go on.

Right, I am no expert on this, but here we go. The docs state:

The look and feel of the Timeseries, XY, and Bar charts may be modified through scripting.

This suggests to me that it is not really the place for data manipulation. Is it not possible to only get the required data at the data source level?

If not, you may be able to use the data argument of the configureChart function to manipulate the chart. You will likely need to do this via the JFreeChart API. I have never done this, so I wouldn’t be best placed to advise on how to do it :sweat_smile:

matthew.ayre is correct – this isn’t the spot to modify the data.

If you have a report data source you want to modify, use a script data source. Each data source has access to the data sources defined above it, so your script data source can modify the data from other data sources. The docs have examples of how to do this.

2 Likes