[ChartController.cs]
List<ChartData> chartData = new List<ChartData>();
Created data here
ViewBag.dataSource = chartData;
[ChartFeature.cshtml]
@Html.EJS().Chart("container").Series(series =>
{
Bind the data source and map the x and y fields from data source as highlighted
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).XName("xValue").YName("yValue")
.DataSource(ViewBag.dataSource).Add();
Other series configurations
}).Render()
|
[ChartController.cs]
List<ChartData> chartData = new List<ChartData>();
Created data here
ViewBag.dataSource = chartData;
[ChartFeature.cshtml]
<button id="click">Change the Data</button>
<div class="row">
@Html.EJS().Chart("container").ChartArea(area => area.Border(br=>br.Color("transparent"))).Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).XName("xValue").YName("yValue")
.Marker(mr => mr.Visible(true)).DataSource(ViewBag.dataSource).Name("Germany").Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).XName("xValue").YName("yValue1")
.Marker(mr => mr.Visible(true)).DataSource(ViewBag.dataSource).Name("England").Add();
Other series configurations
}).Render()
<script>
document.getElementById('click').onclick = () => {
var chart1 = document.getElementById("container").ej2_instances[0];
chart1.series[0].dataSource = [
{xValue: 0, yValue: 36 },
{xValue: 5, yValue: 38 },
{ xValue: 9, yValue: 34 }];
chart1.series[1].dataSource = [
{ xValue: 0, yValue1: 46 },
{ xValue: 5, yValue1: 48 },
{ xValue: 9, yValue1: 44 }];
chart1.series[2].dataSource = [
{ xValue: 0, yValue2: 56 },
{ xValue: 5, yValue2: 58},
{ xValue: 9, yValue2: 54 }];
chart1.series[3].dataSource = [
{ xValue: 0, yValue3: 66 },
{ xValue: 5, yValue3: 68 },
{ xValue: 9, yValue3: 64 }];
}
</script>
|