This is a question about creating a Highcharts Donut chart that includes multiple series.
In this scenario, I have dynamic key properties xData
and yData
from a JSON input data model:
xData= ["Phase", "Step", "Task"];
yData = ["VPhase", "VStep", "VTask"]
inputArray = [
{ Phase: "Phase 1", VPhase: 100, Step: "Step 1", VStep:50, Task: "Task 1", VTask: 20 },
{ Phase: "Phase 1", VPhase: 100, Step: "Step 1", VStep:50, Task: "Task 2", VTask: 30 },
{ Phase: "Phase 1", VPhase: 100, Step: "Step 2", VStep:50, Task: "Task 1", VTask: 25 },
{ Phase: "Phase 1", VPhase: 100, Step: "Step 2", VStep:50, Task: "Task 2", VTask: 25 },
{ Phase: "Phase 2", VPhase: 150, Step: "Step 1", VStep:100,Task: "Task 1", VTask: 60 },
{ Phase: "Phase 2", VPhase: 150, Step: "Step 1", VStep:100,Task: "Task 2", VTask: 40 },
{ Phase: "Phase 2", VPhase: 150, Step: "Step 2", VStep:50, Task: "Task 1", VTask: 15 },
{ Phase: "Phase 2", VPhase: 150, Step: "Step 2", VStep:50, Task: "Task 2", VTask: 35 }
];
I am looking to group and extract distinct consecutive index values from xData
and yData
in order to create an output array similar to the following structure:
outputArray = [
{
Phase: ["Phase 1", "Phase 2"],
VPhase: [100, 150]
},
{
Step: ["Step 1", "Step 2", "Step 1", "Step 2"],
VStep: [50, 50, 100 ,50]
},
{
Task: ["Task 1", "Task 2", "Task 1", "Task 2", "Task 1", "Task 2", "Task 1", "Task 2"],
VTask: [20, 30, 25, 25, 60, 40, 15, 35]
}
];