PieDataSet
Namespace: Wisej.Web.Ext.ChartJS
Assembly: Wisej.Web.Ext.ChartJS (4.1.0.0)
Specialized data set for the Pie chart.
- C#
- VB.NET
public class PieDataSet : DataSet
Public Class PieDataSet
Inherits DataSet
Add creates a PieDataSet when ChartType is Pie. Each value in Data is a segment, usually with its own color.
Example:
this.chartJS1.ChartType = ChartType.Pie;
this.chartJS1.Labels = new[] { "Rent", "Food", "Other" };
var ds = (PieDataSet)this.chartJS1.DataSets.Add("Expenses");
ds.Data = new object[] { 1200, 450, 300 };
ds.BackgroundColor = new[] { Color.Tomato, Color.Gold, Color.MediumSeaGreen };
Constructors
PieDataSet()
Constructs a new instance of PieDataSet.
Example:
this.chartJS1.ChartType = ChartType.Pie;
this.chartJS1.DataSets.Add(new PieDataSet
{
Label = "Expenses",
Data = new object[] { 1200, 450, 300 }
});
Properties
BackgroundColor
Color[]: Returns or sets the fill colors of the data set. One entry is the default color for all the slices, otherwise each slice can define a background color.
Value: An array of Color values, usually one for each value in Data, or null to use the Chart.js default.
Hides BackgroundColor. When the array contains a single color, it's sent to Chart.js as a single value applied to all the slices.
Example:
var ds = (PieDataSet)this.chartJS1.DataSets.Add("Market Share");
ds.Data = new object[] { 45, 30, 25 };
ds.BackgroundColor = new[] { Color.MediumPurple, Color.Goldenrod, Color.CadetBlue };
BorderColor
Color[]: Returns or sets the border colors of the data set. One entry is the default color for all the slices, otherwise each slice can define a different border color.
Value: An array of Color values, or null to use the Chart.js default.
Hides BorderColor. When the array contains a single color, it's sent to Chart.js as a single value applied to all the slices.
Example:
var ds = (PieDataSet)this.chartJS1.DataSets.Add("Votes");
ds.BorderColor = new[] { Color.Black };
ds.BorderWidth = 1;
HoverBackgroundColor
Color[]: Returns or sets the hover colors of the data set. One entry is the default color for all the slices, otherwise each slice can define a different hover background color.
Value: An array of Color values, or null to use the Chart.js default.
Maps to the Chart.js dataset "hoverBackgroundColor" property. When the array contains a single color, it's sent to Chart.js as a single value applied to all the slices.
Example:
var ds = (PieDataSet)this.chartJS1.DataSets["Votes"];
if (ds != null)
{
ds.HoverBackgroundColor = new[] { Color.DarkSlateGray };
this.chartJS1.Update();
}