Available in the Full Version
Pie Chart - Using ASP.NET MVC
This is a basic example showing the pie chart created with the ASP.NET MVC helper.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
Code View
Copy to Clipboard
@using Infragistics.Web.Mvc @using IgniteUI.SamplesBrowser.Models @model IgniteUI.SamplesBrowser.Models.Financial.FinancialDataCollection <!DOCTYPE html> <html> <head> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.dv.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.lob.js"></script> </head> <body> <style type="text/css"> .ui-slider-handle.ui-state-focus { outline: none 0; } #chart { position: relative; float: left; margin-right: 10px; margin-bottom: 10px; } #legend { position: relative; float: left; } .tooltip { font-weight: bold; } </style> @(Html.Infragistics().PieChart(Model.AsQueryable()) .ID("chart") .Width("435px") .Height("435px") .ValueMemberPath(data => data.Budget) .LabelMemberPath(data => data.Label) .ExplodedSlices("0 1") .RadiusFactor(.8) .Legend(leg => leg.ID("legend").LegendType(LegendType.Item)) .AllowSliceExplosion(true) .ShowTooltip(true) .TooltipTemplate("<div class='tooltip'>${item.Label}</div><div>" + "Budget" + ": ${item.Budget}</div>") .DataBind() .Render() ) </body> </html>
using IgniteUI.SamplesBrowser.Models.Financial; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace IgniteUI.SamplesBrowser.Controllers { public class PieChartController : Controller { // // GET: /PieChart/ [ActionName("aspnet-mvc-helper")] public ActionResult AspNetMvcHelper() { FinancialDataCollection data = new FinancialDataCollection(); return View("aspnet-mvc-helper", data); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace IgniteUI.SamplesBrowser.Models.Financial { public class FinancialDataCollection : List<FinancialDataPoint> { public FinancialDataCollection() { this.Add(new FinancialDataPoint { Spending = 20, Budget = 60, Label = "Administration", }); this.Add(new FinancialDataPoint { Spending = 80, Budget = 40, Label = "Sales", }); this.Add(new FinancialDataPoint { Spending = 80, Budget = 40, Label = "Marketing", }); this.Add(new FinancialDataPoint { Spending = 20, Budget = 60, Label = "Development", }); this.Add(new FinancialDataPoint { Spending = 60, Budget = 20, Label = "Customer Support", }); this.Add(new FinancialDataPoint { Spending = 20, Budget = 60, Label = "IT", }); } } public class FinancialDataPoint { public string Label { get; set; } public double Spending { get; set; } public double Budget { get; set; } public string ToolTip { get { return String.Format("{0}, Spending {1}, Budget {2}", Label, Spending, Budget); } } } }