The quick start guides you through the steps of adding a FlexRadar chart to your MVC web application and add data to it.
Follow the steps given below to get started:
Create a new MVC application using the ComponentOne or VisualStudio templates. For more information about creating an MVC application, see Configuring your MVC Application topic.
Sale.cs
). For more information on how to add a new model, see Adding Controls.Sale.cs
model. We are using Sale
class to represent sales data in the database. Each instance of Sale object will correspond to the data on the FlexChart.Sale.cs |
Copy Code
|
---|---|
using System.Collections.Generic; namespace FlexRadarChart.Models { public class Sale { public int Id { get; set; } public string Country { get; set; } public int Downloads { get; set; } public int Sales { get; set; } public static List<Sale> GetData() { var countries = "US,Germany,UK,Japan,Italy,Greece".Split(new char[] { ',' }); List<Sale> data = new List<Sale>(); for (var i = 0; i < countries.Length; i++) { data.Add(new Sale() { Country = countries[i], Downloads = ((i % 4) * 40) + 20, Sales = ((i % 7) * 25) + 20 }); } return data; } } } |
To add a FlexRadar chart to the application, follow these steps:
Add a new Controller
FlexRadarController
).C# |
Copy Code
|
---|---|
using C1.Web.Mvc; using C1.Web.Mvc.Serializition; using C1.Web.Mvc.Chart; |
FlexRadarController.cs |
Copy Code
|
---|---|
public ActionResult Index() { return View(Models.Sale.GetData()); } |
FlexRadarController.
Index()
.Index.cshtml |
Copy Code
|
---|---|
@model IEnumerable<Sale> @using C1.Web.Mvc.Chart <c1-flex-radar binding="Downloads" binding-x="Country" height="400px" width="500px" chart-type="Column" legend-position="Top"> <c1-items-source source-collection="Model" /> <c1-flex-radar-series name="Downloads" /> <c1-flex-radar-series name="Sales" binding="Sales" /> </c1-flex-radar> |