Highcharts (barchart) not displaying axis values from datatables

Highcharts (barchart) not displaying axis values from datatables

Noodles12Noodles12 Posts: 107Questions: 38Answers: 2

I am working on a page that uses datatables to retrieve highcharts. Charts for Button one (pie chart) and Button three (column chart) are fine. They show the X axis and Y axis values from the corresponding tables below. However, the problem I am facing is with Button two - Bar chart. Similar to other charts, for the bar chart too, I am trying to display the axis values from the datatable below. Column 2022 values should be X axis and Percent column as Y axis. The legend should also display X axis (column 2022) data. Not sure what am I missing.
Here is my code - https://codepen.io/Shawnny-Tandon/pen/bGJeOev

Answers

  • Noodles12Noodles12 Posts: 107Questions: 38Answers: 2

    sorry something happened to my code earlier incase u looked at it earlier. Please check my codepen again -
    https://codepen.io/Shawnny-Tandon/pen/bGJeOev

  • kthorngrenkthorngren Posts: 20,331Questions: 26Answers: 4,774

    This is a Highcharts config issue not Datatables. Take a look at the Highcharts bar chart example to see the expected data structure, for example:

        series: [{
            name: 'Year 1990',
            data: [631, 727, 3202, 721]
        }, {
            name: 'Year 2000',
            data: [814, 841, 3714, 726]
        }, {
            name: 'Year 2018',
            data: [1276, 1007, 4561, 746]
        }]
    

    But. you are using this data structure for the bar chart:

    [
        {
            "name": "AAA",
            "y": 51.9
        },
        {
            "name": "BBB",
            "y": 18.6
        }
    ]
    

    This is the structure used for a Pie Chart. I think you will want to return a structure similar to the column chart.

    In the future please use the Highcharts forum or Stack Overflow for Highcharts questions. This forum is for Datatables specific questions.

    Kevin

Sign In or Register to comment.