Creating chart on server side

Is there a way to create a chart server side in .NET core ?
I realize we can pass in the image to the API, but what if I want to reproduce the same chart on sever ?

1 Reply 1 reply marked as answer

SM Srihari Muthukaruppan Syncfusion Team February 18, 2021 07:33 AM UTC

Hi Voss, 
  
We have analysed your query. From that, we would like to let you know that it is not possible to completely render the chart in code behind. Hence we suggest you to bind the series for chart in code behind as a collection for provided data source. We have prepared sample for your reference. Please check with the below code snippet and sample. 
  
Code Snippet 
  
Index.cshtml 
  
<ejs-chart id="myContainer" series="@ViewBag.seriesCollection"> 
</ejs-chart> 
  
HomeController.cs 
  
public IActionResult Index() 
{ 
   List<ChartSeries> collection = new List<ChartSeries>(); 
   List<StackedBar100ChartData> chartData = new List<StackedBar100ChartData> 
   { 
      new StackedBar100ChartData { x= "19.8.2019", y0= 1.1, y1=0.4, y2=0.6, y3=0.8, y4=0.1, y5=12 } 
      //…              
   }; 
   string[] colors = new string[] { "lime","red","blue","red","blue","lime"}; 
   for(int i =0;i<6; i++) 
   { 
       ChartSeries series = new ChartSeries(); 
       series.XName = "x"; 
       series.YName = "y"+i; 
       series.DataSource = chartData; 
       series.Fill = colors[i]; 
       series.Type = Syncfusion.EJ2.Charts.ChartSeriesType.StackingBar100; 
       collection.Add(series); 
   } 
   ViewBag.seriesCollection = collection; 
   return View(); 
} 
  
Sample 
  
Kindly revert us, if you have any concerns. 
  
Regards, 
Srihari M 


Marked as answer
Loader.
Up arrow icon