Nevron Open Vision Documentation
Chart / Charts / Types / Pie / Pie- Chart
In This Topic
    Pie- Chart
    In This Topic

     A pie chart is a circular chart which represents portions of data as slices. The following code shows how to create a simple pie chart:

    C#
    Copy Code

    // create a dock panel with label and chart

    NDockPanel dockPanel = new NDockPanel();

    chartView.Surface.Content = dockPanel;

    // crete a docked label

    NLabel label = new NLabel();

    label.Text = "My First Pie Chart";

    label.Margins = new NMargins(10);

    label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 12);

    label.TextFill = new NColorFill(NColor.Black);

    label.TextAlignment = ENContentAlignment.MiddleCenter;

    NDockLayout.SetDockArea(label, ENDockArea.Top);

    dockPanel.AddChild(label);

    // create a new cartesian chart

    NPieChart pieChart = new NPieChart();

    pieChart.Margins = new NMargins(10);

    NDockLayout.SetDockArea(pieChart, ENDockArea.Center);

    dockPanel.AddChild(pieChart);

    // create a bar series

    NPieSeries pieSeries = new NPieSeries();

    NPieDataPoint slice1 = new NPieDataPoint(10);

    slice1.Fill = new NColorFill(NColor.Red);

    pieSeries.DataPoints.Add(slice1);

    NPieDataPoint slice2 = new NPieDataPoint(20);

    slice2.Fill = new NColorFill(NColor.Green);

    pieSeries.DataPoints.Add(slice2);

    NPieDataPoint slice3 = new NPieDataPoint(30);

    slice3.Fill = new NColorFill(NColor.Blue);

    pieSeries.DataPoints.Add(slice3);

    pieChart.Series.Add(pieSeries);

    See Also