Log in to like this post! The Ignite UI Doughnut Chart and its features Marina Stoyanova / Wednesday, October 16, 2013 Using the Doughnut chart you can easily display multiple rings at the same time, capable of binding the same or a different collections. This chart is similar to the pie chart and is used to show categorical statistics expressed in percentages. It posses various options, allowing you to customize its appearance and the way you data is visualized. For starters In the current release this control is CTP, so be aware that you may face some difficulties. Adding doughnut chart to your application is easy. First we are going to show you how to initialize it in JavaScript and then in ASP.NET MVC. In order to add this jQuery control to your application,all you need to do is create a HTML tag to host your chart and then add the following lines: <script> $(function () { var data = [ { "savings": 230, "Budget": 600, "Label": "Adi" }, { "savings": 100, "Budget": 400, "Label": "Sam" }, { "savings": 250, "Budget": 550, "Label": "Tom" }, { "savings": 22, "Budget": 300, "Label": "Mark" }, { "savings": 130, "Budget": 650, "Label": "Dave" }, { "savings": 54, "Budget": 200, "Label": "Sally" } ]; $("#chart").igDoughnutChart({ width: "550px", height: "550px", innerExtent: 10, series: [ { name: "Budget", labelMemberPath: "Label", valueMemberPath: "Budget", dataSource: data, labelsPosition: "bestFit" }, { name: "savings", labelMemberPath: "Label", valueMemberPath: "savings", dataSource: data, labelsPosition: "bestFit" } ] }); }); script> In this example the Doughnut Chart is bound to JSON data. As we said this control supports single or multiple ring series and each ring can visualize separate data. In the preceding code you can see how to create a chart with two rings, displaying different data. Now that you know how to include that chart in JS let’s see how to do it in ASP.NET MVC. For the purpose of our sample we are going to use Entity Framework and get the data from there. First you need a data base- we are going to use the AdventureWorks database and we are going to create a new model adding an ADO.NET Entity Data Model.When you choose the data base you are going to use mark the tables you need for your application and you are ready to use the data. In HomeController.cs file add the following lines, they show you how to take the first 10 rows of the particular table. Of course we are making a razor application, so you can always use LINQ to manipulate the data base and extract the the needed information. public ActionResult Data() { AdventureWorksEntities context = new AdventureWorksEntities(); return View(context.Products.Take(10)); } There is one last step to perform before our control is ready and that is initializing the Doughnut Chart in our corresponding View file. @(Html.Infragistics().DoughnutChart() .ID("Chart1") .InnerExtent(30) .Width("100%") .Height("500px") .Series(s => { s.Ring("Budget", Model.AsQueryable()) .LabelMemberPath("Name") .ValueMemberPath("ReorderPoint"); }).Render()) Shortly this is how you can add Doughnut Chart control to your application. Now it is up to you to customize it and make it unique and suitable for your needs. Customizing the Chart The options can be divided in two groups: options for the whole doughnut and options for the series.The first group contains options that control the behavior of all of the slices, while the second group allow you to choose the slices color, labels, style and etc. Doughnut options There are two basic options that corresponds to the slices actions. The allowSliceExplotion option makes the slices able to pop out of their places when a user click on them and the allowSliceSelection option makes the slices selectable – meaning that when a user click on a particular slice it can change its style or trigger a client event. Both of those options are of Boolean type, so if you want to use them set their value to true. You should also initialize the sliceClick event if you want the mentioned properties to work. sliceClick: function (e, ui) { ui.slice.isSelected = !ui.slice.isSelected; ui.slice.isExploded = !ui.slice.isExploded; } allowSliceExplosion: true, allowSliceSelection: true It is a doughnut chart so it has a “blank circle” for a center, but actually you can control the radius of that circle with the innerExtent option and make it as big as you want or loose it. innerExtent: 10 Series options There are plenty of options by which you can manipulate the series. We are going to look at some of them, but you can find the whole list in the API documentation. You can have as many slices for you chart as you need and it is useful if they all have different color – that way you will be able to notice the distinction of their size easily. For that purpose you can use the brushes property. It defines the palette from which automatically assigned slice brushes are selected. The value provided should be an array of CSS color strings. brushes: ["#B284BE", "#5D8AA8", "#C9FFE5", "#7CB9E8", "#F19CBB", "#FAEBD7"] Another handy option is the legend. You can specify a div element for it, but if none is found a new element will be created and inserted after the chart element. In our case we have a HTML tag for the legend. <table> <tr> <td> <div id="chart">div> td> <td style="vertical-align: top;"> <table> <tr> <td> <div id="legend1">div> td> tr> <tr> <td> <div id="legend2">div> td> tr> table> td> <td> <div id="selectedItem">div> td> tr> table> series: [ { . . . legend: { element: "legend1" }, }, { . . . legend: { element: "legend2" } } ] The other option we are going to pay attention to is the tool tip. Basically it displays a text when your mouse hover a particular slice. To activate that option set the showToolTip property to true, and then use the tooltipTemplate property to specify which template to display. In our case the inner ring display the budget for each person and the outer ring displays the their savings. <script id="budgetTooltipTemplate" type="text/x-ig-tmpl"> ${item.Label}, Budget: $${item.Budget} script> <script id="savingsTooltipTemplate" type="text/x-ig-tmpl"> ${item.Label}, Saves: $${item.savings} script> series: [ { . . . showTooltip: true, tooltipTemplate: "budgetTooltipTemplate" }, { . . . showTooltip: true, tooltipTemplate: "savingsTooltipTemplate", } ] As we said you can select the slices and it is logical to be able to change their appearance when this action take place. So you can use the selectedStyle option to change their color. selectedStyle: { fill: "lightpink", stroke: "black" } Ready to use So customizing the chart allows you to make it unique and visualize your data in an attractive way. This Ignite UI control is original and provides an easy way to show categorical statistics expressed in percentages. With its multiple ring series layout you can show different data at the same time. You can find more about the Doughnut Chart and its features in the products page. You can find the sample here or you can see the sample in JSFiddle. You can follow us on Twitter @Infragistics and stay in touch on Facebook, Google+ and LinkedIn!