How to change data in CrossesAt using data ViewBag

#Views 

px.CrossesAt(ViewBag.CrossesAt).PlaceNextToAxisLine(false).LabelStyle(ls => ls.Size("8px").FontFamily("Arial Black")).MajorTickLines(mt => mt.Width(0)).LineStyle(ls => ls.Width(2).Color("red")).ValueType(Syncfusion.EJ2.Charts.ValueType.Category).MajorGridLines(mg => mg.Width(0));


#Controller

ViewBag.CrossesAt = chartDirectOvertime.Where(y => y.x == day).Select(x => x.yValue2).FirstOrDefault();  


1 Reply

SS SaiGanesh Sakthivel Syncfusion Team September 30, 2022 07:12 AM UTC

Hi Maulana,


Greetings from Syncfusion.


We can set the x axis to cross at specific point by setting the CrossesAt property in controller side and same is set in the CrossesAt property in the PrimaryXAxis. We have created a simple MVC application to demonstrate the same and it can be downloaded from the below link.


Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ChartBarCrossesAt-278121634


Code Snippet:


Controller.cs

ViewBag.CrossesAt = 1;


Index.cshtml

PrimaryXAxis(

            px =>

            {

                px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).MajorGridLines(mg => mg.Width(0)).

                Title("Food").CrossesAt(ViewBag.CrossesAt);


Screenshot:



Kindly, revert us if you have any concerns.


Regards,

Swetha


Loader.
Up arrow icon