- Home
- Forum
- ASP.NET MVC - EJ 2
- How do I create two xName values in a chart?
How do I create two xName values in a chart?
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column)
.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]
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.
|
HomeController.cs 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>(); categoryOne.Add(category); one.Categories = categoryOne; multilevels.Add(one); ViewBag.multiLevelLabels = multilevels; } Index.cshtml @Html.EJS().Chart("container").PrimaryXAxis(py => py. MultiLevelLabels(ViewBag.multiLevelLabels)).Load("onChartLoad").Render() <script> 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', }, //… ]
} ]; } </script> |
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Multilevellabel1167170295.zip
Please revert us if you have any concerns.
Regards,
Durga Gopalakrishnan.
Thankyou for the answer, I'll try implement this on my project. I'll be back later to mark your answer
Muqofa,
Most welcome. Please get back to us if you have any other concerns. We are always happy in assisting you.
- 3 Replies
- 3 Participants
-
MS Muqofa Syinagha
- Mar 22, 2023 08:56 AM UTC
- Mar 24, 2023 11:16 AM UTC