We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do I create two xName values in a chart?


.Marker(mr => mr.DataLabel(dl => dl.Visible(true).Font(ff => ff.FontWeight("600").Color("#ffffff")).EnableRotation(true).Angle(270).Position(Syncfusion.EJ2.Charts.LabelPosition.Middle))).XName("x").YName("yValue1").DataSource(ViewBag.dataSource).Name("Actual").Width(2).Add();

2020-> [1st, 2nd]

2021-> [1st, 2nd]

2022-> [1st, 2nd]

2023-> [Jan - Dec]


3 Replies

UA Udhayakumar Anand Syncfusion Team March 23, 2023 02:25 PM UTC

Hi Muqofa,

Greetings from Syncfusion.

We suggest you to multi level labels to achieve your required scenario. We have prepared sample based on your requirement. Please check with the below snippet and sample.


public ActionResult Index()


List<ChartMultiLevelLabel> multilevels = new List<ChartMultiLevelLabel>();

            ChartMultiLevelLabel one = new ChartMultiLevelLabel();

            ChartCategory category = new ChartCategory();

            category.Start = "-0.5";

            category.End = "0.5";

            category.Text = "2020 AAAA";

List<ChartCategory> categoryOne = new List<ChartCategory>();


one.Categories = categoryOne;


            ViewBag.multiLevelLabels = multilevels;



@Html.EJS().Chart("container").PrimaryXAxis(py => py. MultiLevelLabels(ViewBag.multiLevelLabels)).Load("onChartLoad").Render()


    function onChartLoad(args) {

        args.chart.series[0].connector.width = 0;

        args.chart.primaryXAxis.border = { type: "Rectangle", width: 1 };

        args.chart.primaryXAxis.multiLevelLabels = [



                border: { type: 'Rectangle' },

                categories: [

                    { start: -0.5, end: 0.5, text: '2020 AAAA', },








Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Multilevellabel1167170295.zip

Please revert us if you have any concerns.


Durga Gopalakrishnan.

MS Muqofa Syinagha replied to Udhayakumar Anand March 24, 2023 01:09 AM UTC

Thankyou for the answer, I'll try implement this on my project.  I'll be back later to mark your answer

DG Durga Gopalakrishnan Syncfusion Team March 24, 2023 11:16 AM UTC


Most welcome. Please get back to us if you have any other concerns. We are always happy in assisting you.

Live Chat Icon For mobile
Up arrow icon