Category / Section
How to use the redraw method in chart?
1 min read
The redraw method is used to dynamically refresh the chart content and redraw the chart based on the updated values. Refer to the following code example that explains how to redraw and update the chart on button click by using redraw method.
CSHTML
@(Html.EJ().Chart("container") .Series(s => { s.Points(p => { p.X("Jan").Y(33).Add(); p.X("Feb").Y(33).Add(); p.X("Mar").Y(33).Add(); p.X("Apr").Y(33).Add(); p.X("May").Y(33).Add(); p.X("Jun").Y(33).Add(); p.X("Jul").Y(33).Add(); p.X("Aug").Y(33).Add(); p.X("Sep").Y(33).Add(); p.X("Oct").Y(33).Add(); p.X("Nov").Y(33).Add(); p.X("dec").Y(33).Add(); }).Name("India").Type(SeriesType.Spline) .Marker(marker=> marker.Shape(ChartShape.Circle) .Visible(true) .Size(sz=> sz.Width(6).Height(6)) ).Add(); }) ) <button onclick="Redraw()">Redraw</button> <script type="text/javascript"> function Redraw() { chartObj = $("#container").ejChart("instance"); chartObj.model.series[0].points[5].y = 5; chartObj.model.series[0].type="column"; $("#container").ejChart("redraw"); } </script>
The following screenshot displays the Chart on page load.
The following screenshot displays the Chart after calling Redraw method.