1

I'm using angular 11, typescript

I have this array structure that I want to import in highcharts, but I don't know how to. I'm using api response to get the data and every time a user take a new quiz it adds another set of quiz_title, passed and failed.

 "message": "Remarks successfuly shown",
    "error": false,
    "error code": 200,
    "line": "line215215",
    "quizRemarks": [
        {
            "Quiz_Title": "Acts and Regulation",
            "Passed": "24",
            "Failed": "6"
        },
        {
            "Quiz_Title": "Breakdowns and Accidents",
            "Passed": "7",
            "Failed": "3"
        },
        {
            "Quiz_Title": "Coupling and Uncoupling Semi-Trailers",
            "Passed": "2",
            "Failed": "8"
        },
        {
            "Quiz_Title": "Defensive Driving",
            "Passed": "2",
            "Failed": "37"
        },
        {
            "Quiz_Title": "Driver Health and Safety",
            "Passed": "7",
            "Failed": "1"
        },
        {
            "Quiz_Title": "General Knowledge",
            "Passed": "4",
            "Failed": "14"
        }
    ]
}
2

1 Answer 1

1

Is this an output that you want to achieve?

const chartData = dataFromServer.map(data => ({
  name: data["Quiz_Title"],
  data: [{
      name: 'Passed',
      y: parseInt(data["Passed"])
    },
    {
      name: 'Failed',
      y: parseInt(data["Failed"])
    }
  ]
}));

https://jsfiddle.net/BlackLabel/dz1wheut/

Sign up to request clarification or add additional context in comments.

2 Comments

Yes that is the output that I want, here is my code I tried it and it's not working jsfiddle.net/08v5bzgw/#&togetherjs=0a21RJhOQN
It's not working because it's not Angular envoirment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.