I’m working on an Ignition report where I have a main query that returns a list of stations. For each station, I have a nested query that retrieves related event data specific to that station.
In my report, I display a table with one row per station, and inside each row, I embed a chart that should show the station’s event data. I’m using the configureChart(chart, data) scripting function to customize the chart to display a timeline, but the data parameter contains the full dataset, and I have no direct access to the nested query results related to that specific station or to the current row index of the report table.
How can I access the nested query results for each station inside the configureChart script for the chart embedded in that station’s row?
Hmm. Unfortunately, the data you have access to in configureChart is already flattened so you don't have access to the nested data structures.
The first workaround that comes to my mind is a scripted datasource that iterates through the nested query results (where you can access them) and generates 'top level' data keys that are indexed appropriately. I'm not sure the best way to access that index from configureChart, but it might be an option...
I ended up solving this by using the row number from the table as the X-axis label. In the configureChart function, I retrieved the row index to look up the stationId from the top-level query results. Then I used that stationId to filter the events dataset.
plot = chart.getPlot()
domain_axis = plot.getDomainAxis()
if domain_axis is not None:
row = domain_axis.getLabel()
target_station_id = data['stations'].getValueAt(int(row)-1,0)
sap_timeline = data['sap_timeline']
filtered_sap_timeline = sap_timeline[str(target_station_id)]