Kendo Chart Axis Label (categoryAxis)

0 Answers 17 Views
Charts
j
Top achievements
Rank 1
j asked on 27 Feb 2024, 05:51 AM

Hi. I have a single JSON Array like this:

[{
            "country": "Spain",
            "year": "2008",
            "unit": "GWh",
            "solar": 2578,
            "hydro": 26112,
            "wind": 32203,
            "nuclear": 58973
}];

 

And, What I want to do is make this single array into a chart. (I hope the name of the series is the same as the axis text.)

Like this.

but, If I write code like this... All series are included in one category. How can I solve this?


var tempData = [{
    "country": "Spain",
    "year": "2008",
    "unit": "GWh",
    "solar": 2578,
    "hydro": 26112,
    "wind": 32203,
    "nuclear": 58973
}];

$("#chart").kendoChart({
    dataSource: {
        data : tempData
    },
    series:
    [{
        field: "nuclear",
        name: "Nuclear"
    }, {
        field: "hydro",
        name: "Hydro"
    }, {
        field: "wind",
        name: "Wind"
    }],
    categoryAxis: {
      categories: ["Nuclear", "Hydro", "Wind"]
    }
});

 

 

 

Nikolay
Telerik team
commented on 29 Feb 2024, 12:13 PM

Hello J Jay,

What you are trying to achieve requires only one categoryAxis category and then you can use series.labels to display labels:

Dojo demo: https://dojo.telerik.com/EModOqeS

Please examine this and let me know if you have any questions.

Regards,

Nikolay

No answers yet. Maybe you can help?

Tags
Charts
Asked by
j
Top achievements
Rank 1
Share this question
or