How to create CrossesAt Refresh, CrossesAt data function not working

@Html.EJS().Chart("OTPersonDirect").Height("88%").Width("100%").PrimaryXAxis(px => {

px.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)).CrossesAt(ViewBag.CrossesAt);

})


//Fuction Refresh

var CrossesAt = document.getElementById('OTPersonDirect').ej2_instances[0];

CrossesAt.CrossesAt = result.CrossesAt;

CrossesAt.refresh();



CrossesAt data function not working



1 Reply

SB Swetha Babu Syncfusion Team October 4, 2022 07:09 AM UTC

Hi Maulana,


Greetings from Syncfusion.


We do not need to refresh the Chart after setting the CrossesAt property from the controller. We can just directly assign the ViewBag.CrossesAt value to the CrossesAt property in the PrimaryYAxis. 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/ChartCrossesAt-1201550570


Code Snippet:


Index.cshtml file:


PrimaryYAxis(

            py =>

            {

                py.

                LabelFormat("{value}B").MajorGridLines(mg => mg.Width(0)).CrossesAt(ViewBag.CrossesAt);

            })


Controller file:


ViewBag.CrossesAt = 1;



Screenshot:



Kindly, revert us if you have any concerns.


Regards,

Swetha


Loader.
Up arrow icon