[CS]
List<ChartData> list = new List<ChartData>();
using (var fs = File.OpenRead(path))
using (var reader = new StreamReader(fs))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');
list.Add(new ChartData(values[0], Convert.ToDouble(values[1])));
}
}
Syncfusion.JavaScript.Web.Chart chart = new Syncfusion.JavaScript.Web.Chart();
chart.PrimaryXAxis.ValueType = AxisValueType.Category;
Series series1 = new Series();
series1.XName = "Xvalue";
series1.YName = "YValue1";
chart.DataSource = list;
chart.DataBind();
chart.Size.Height = "450";
chart.Size.Width = "600";
chart.Model.Series.Add(series1);
holder.Controls.Add(chart); |
public IActionResult Index()
{
List<ChartSeries> collection = new List<ChartSeries>();
List<ChartData> chartData = new List<ChartData>
{
new ChartData { xValue = "2014", yValue = 21, yValue1 = 21 },
new ChartData { xValue = "2015", yValue = 24, yValue1 = 31},
new ChartData { xValue = "2016", yValue = 36, yValue1 = 14 },
new ChartData { xValue = "2017", yValue = 38, yValue1 = 31 },
new ChartData { xValue = "2018", yValue = 54, yValue1 = 11 },
new ChartData { xValue = "2019", yValue = 57, yValue1 = 24 },
new ChartData { xValue = "2020", yValue = 70, yValue1 = 16 },
};
ViewBag.dataSource = chartData;
ChartSeries series1 = new ChartSeries();
series1.XName = "xValue";
series1.YName = "yValue";
series1.DataSource = chartData;
series1.Fill = "orange";
series1.Name = "Series1";
series1.Type = Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn;
series1.Trendlines = new List<ChartTrendline>();
series1.Segments = new List<ChartSegment>();
series1.Visible = true;
ChartSeries series2 = new ChartSeries();
series2.XName = "xValue";
series2.YName = "yValue1";
series2.DataSource = chartData;
series2.Fill = "green";
series2.Name = "Series2";
series2.Type = Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn;
series2.Trendlines = new List<ChartTrendline>();
series2.Segments = new List<ChartSegment>();
series2.Visible = true;
collection.Add(series1);
collection.Add(series2);
ViewBag.series1 = collection;
return View();
}
public class ChartData
{
public string xValue;
public double yValue;
public double yValue1;
} |
<ejs-chart id="splineContainer" title="Mobile Game Market by Country" series=" ViewBag.series1">
<e-chart-primaryxaxis valueType="Category"/>
<e-chart-tooltipsettings enable="true"></e-chart-tooltipsettings>
<e-chart-legendsettings toggleVisibility="true"></e-chart-legendsettings>
</ejs-chart> |
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|