How to use xy chart to display different items (maximum of 4 items), per every x-value?

Hello, I am looking to design something like this using an x-y chart:
As you can see in the image below, for every x-value there are 4 bars displayed, so every x-value can be split into 4, if there's data available. Sometimes there is data available to split an axis into 2, 3, or even sometimes, there is not data for an x-value... For example, there might not be any "rejects" from Nest 1 (because this machine has 16 Nest)

As of now, this is what I have in the perspective session:

My question is how can I split an axis value to display 4 different bars?
In this case, my data is this:

As you can see, based on my current data, I would have to slip the 13 value into 2 bars (one bar corresponding to two 19s and eighteen 23s.
Four is the maximum of bars I can split an x-axis value because there is the possibility for me to have 4 different numbers of FailCodes per NestID

I am thinking that I may have to change my dataSource "rejectCounts" binding ... by changing the Return format from Dataset to Json and add a transform. Not sure if that would be the best approach... I am still confused about how should I split an x-value axis into 1-4 bars... Any suggestion for me would be highly appreciated. Thank you.

I believe you will want your NestID to be your x-axis value, and your 4 different FailCodes to be 4 different series, with the count_failcode to be the value of each series.
Your data would look something like this:

You would have 4 series (one per failCode), with the data prop looking something like this:

If you convert your output to json, something similar to this script should work to transform your data:

newData = []
for row in value:
	key = "failCode" + str(row['FailCode'])
	newData.append({'NestID': row['NestID'], key: row['countFailCode']})
1 Like

Hi Daniel, Thank you so much. I'll will try this out now. Many, many thanks

I am not sure why this is giving me an Error_ScriptEval. Any ideas?

On line 2 you are using system.dataset.toPyDataSet() which expects a Dataset, however you are providing a JSON, not a DataSet. The line is not needed, and is probably the line throwing the error.

Thank you so much @Daniel.Snyder . Many, many Thanks!