The quick start guides you through the steps of adding a FlexPie control 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.
FlexPieDataSource.cs
). See Adding controls to know how to add a new model.C# |
Copy Code
|
---|---|
public class FlexPieDataSource { public string Country { get; set; } public int Sales { get; set; } public static IEnumerable<FlexPieDataSource> GetData() { var countries = new[] { "US", "UK", "China", "France", "German", "Italy" }; var rand = new Random(0); List<FlexPieDataSource> list = new List<FlexPieDataSource>(); for (int i = 0; i < 6; i++) { var sales = rand.Next(1, 5); list.Add(new FlexPieDataSource { Sales = sales, Country = countries[i] }); } return list; } } |
Complete the following steps to initialize a FlexPie control.
Add a new Controller
Default1Controller
).C# |
Copy Code
|
---|---|
using C1.Web.Mvc; using C1.Web.Mvc.Serializition; using C1.Web.Mvc.Chart; |
Index()
with the following method.
C# |
Copy Code
|
---|---|
public ActionResult QuickStart() { return View(FlexPieDataSource.GetData()); } |
Add a View for the Controller
QuickStartController
to open it.QuickStart()
.Index.cshtml |
Copy Code
|
---|---|
<c1-flex-pie binding-name="Country" binding="Sales"> <c1-items-source source-collection="Model"></c1-items-source> </c1-flex-pie> |