PieDataSet
Namespace: Wisej.Web.Ext.ChartJS4.Models
Assembly: Wisej.Web.Ext.ChartJS4 (4.1.0.0)
Data set for pie and doughnut charts.
- C#
- VB.NET
public class PieDataSet : ChartDataSet
Public Class PieDataSet
Inherits ChartDataSet
Unlike the other specialized datasets, Type is not set, so the dataset is drawn using the chart's ChartType (Pie or Doughnut). Colors are usually assigned per slice by setting BackgroundColor to an array.
Example:
var chart = new ChartJS4 { ChartType = ChartType.Doughnut };
chart.Labels = new[] { "Red", "Blue", "Yellow" };
chart.DataSets.Add(new PieDataSet
{
Label = "Votes",
Data = new object[] { 300, 50, 100 },
BackgroundColor = new object[] { Color.Red, Color.Blue, Color.Gold }
});
Constructors
PieDataSet()
Initializes a new instance of the PieDataSet class.
Type is left null, so the chart's type (pie or doughnut) is used.
Example:
var pie = new PieDataSet();
pie.Data = new object[] { 60, 25, 15 };
chart.DataSets.Add(pie);
Properties
Weight
Int32: Returns or sets the relative thickness of the dataset (doughnut only). (Default: 1)
Value: An Int32. The default is 1. Maps to the Chart.js weight option.
When a doughnut chart has several datasets, each ring's thickness is proportional to its weight relative to the sum of all weights.
Example:
chart.DataSets.Add(new PieDataSet { Label = "Outer", Data = new object[] { 5, 3 }, Weight = 2 });
chart.DataSets.Add(new PieDataSet { Label = "Inner", Data = new object[] { 4, 4 }, Weight = 1 });
Methods
ResetWeight()
Resets the Weight property to its default value of 1.
Used by the Visual Studio designer when the user resets the property.
Example:
pie.ResetWeight();
ShouldSerializeWeight()
Determines whether the Weight property should be serialized by the designer.
Returns: Boolean. true if Weight is not 1 (its default value); otherwise false.
Used by the Visual Studio designer to decide whether to generate code for the property.
Example:
if (pie.ShouldSerializeWeight())
pie.ResetWeight();