I have a unique set of data to display in a Highcharts column stack chart. Please see the data and code below:
var customData = [
{
"personId": "ff6b9c90-3961-4995-b05c-eaa8c0689f7c",
"pid": "PID-2",
"averageCycleTime": 3.216666666666667,
"idealCycleTime": 5,
"cycleDetails": [
{
"cycleId": "4019551e-b6b8-45cb-8df6-1c8c3c9d8995",
"visionCycleId": "1",
"cycleDuration": 4.433333333333334,
"actionDetails": null
},
...
]
},
{
...
}
]
Using the JavaScript snippet provided, I'm converting this data into Highcharts series format.
let sortedArray : any;
sortedArray = customData.sort((a : any,b : any)=> a.pid.localeCompare(b.pid));
let personIDList = sortedArray.map((pItems : any,idx : any)=> pItems.pid);
const series = customJson.map((value, key) => {
return {
name: `Cycle-${key + 1}`,
data: value.cycleDetails.map((v) => ({
y: v.cycleDuration,
videoId: v.cycleId,
})),
};
});
In the above process, I organize the array based on PID for category setup. You can now review the chart configurations with the data provided.
{
chart: {
type: 'column'
},
title: false,
xAxis: {
categories: this.personIDList,
labels :{
style : {
color : '#1e272e',
cursor : 'pointer'
}
}
},
...
The result of implementing the above code is shown in the provided link. However, the arrangement of bars seems shuffled as per PID. The desired outcome should align each PID's details within the same column, resembling the second image linked.
My anticipated data chart visualization would resemble the following: