From ef5b3eb90fed88a592e806091210b38d8e1eb41d Mon Sep 17 00:00:00 2001 From: sshah254 Date: Mon, 11 Jan 2016 20:21:07 -0800 Subject: [PATCH 1/2] Update PieSeries.rst Added the C# code, and VB code to the page. The image also needs to be changed. I don't know how to do that, but will try and figure it out. Thanks, Sandip --- models/series/PieSeries.rst | 103 +++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/models/series/PieSeries.rst b/models/series/PieSeries.rst index 7884de4..53953b7 100644 --- a/models/series/PieSeries.rst +++ b/models/series/PieSeries.rst @@ -30,4 +30,105 @@ Example .. sourcecode:: csharp - var model = new PlotModel { Title = "PieSeries" }; + namespace ExampleLibrary + { + using OxyPlot; + + using OxyPlot.Series; + + [Examples("PieSeries")] + public static class PieSeriesExamples + { + [Example("PieSeries")] + public static PlotModel PieSeries() + { + return CreateExample(); + } + + [Example("PieSeries with inside label color")] + public static PlotModel InsideLabelColor() + { + var model = CreateExample(); + var series = (PieSeries)model.Series[0]; + series.InsideLabelColor = OxyColors.White; + return model; + } + + private static PlotModel CreateExample() + { + var model = new PlotModel { Title = "World population by continent" }; + + var ps = new PieSeries + { + StrokeThickness = 2.0, + InsideLabelPosition = 0.8, + AngleSpan = 360, + StartAngle = 0 + }; + + // http://www.nationsonline.org/oneworld/world_population.htm + // http://en.wikipedia.org/wiki/Continent + ps.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = true }); + ps.Slices.Add(new PieSlice("Americas", 929) { IsExploded = true }); + ps.Slices.Add(new PieSlice("Asia", 4157)); + ps.Slices.Add(new PieSlice("Europe", 739) { IsExploded = true }); + ps.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = true }); + + model.Series.Add(ps); + return model; + } + } + } + + +.. sourcecode: VB + + Create class in a file called PieViewModel.vb + + Imports OxyPlot + Imports OxyPlot.Series + + Public Class PieViewModel + + Private modelP1 As PlotModel + Private modelP2 As PlotModel + Private modelP3 As PlotModel + + Public Sub New() + + modelP1 = New PlotModel() With {.Title = "Pie Sample1", .Subtitle = "created with OxyPlot"} + + Dim seriesP1 = New PieSeries() With {.StrokeThickness = 2.0, .InsideLabelPosition = 0.8, .AngleSpan = 360, .StartAngle = 0} + + 'http://www.nationsonline.org/oneworld/world_population.htm + 'http://en.wikipedia.org/wiki/Continent + + seriesP1.Slices.Add(New PieSlice("Africa", 1030) With {.IsExploded = False, .Fill = OxyColors.PaleVioletRed}) + seriesP1.Slices.Add(New PieSlice("Americas", 929) With {.IsExploded = True}) + seriesP1.Slices.Add(New PieSlice("Asia", 4157) With {.IsExploded = True}) + seriesP1.Slices.Add(New PieSlice("Europe", 739) With {.IsExploded = True}) + seriesP1.Slices.Add(New PieSlice("Oceania", 35) With {.IsExploded = True}) + + modelP1.Series.Add(seriesP1) + + End Sub + + Property Model1() As PlotModel + Get + Return modelP1 + End Get + Set(value As PlotModel) + modelP1 = value + End Set + End Property + + End Class + + Add the following to the XAML file: + + + + + + + From 8ba45aff5fa6054f07dadddeabe5cc7c6123bf0f Mon Sep 17 00:00:00 2001 From: sshah254 Date: Tue, 12 Jan 2016 08:32:26 -0800 Subject: [PATCH 2/2] Update PieSeries.rst Hi, I am no C# guy, but the code included works for me and generates the correct PieChart. If you know someone who knows C# well, please pass it by him. Else, feel free to delete the C# code and include just the VB code. Thanks, Sandip --- models/series/PieSeries.rst | 70 ++++++++++++++----------------------- 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/models/series/PieSeries.rst b/models/series/PieSeries.rst index 53953b7..87735fd 100644 --- a/models/series/PieSeries.rst +++ b/models/series/PieSeries.rst @@ -30,61 +30,43 @@ Example .. sourcecode:: csharp + using OxyPlot; + using OxyPlot.Series; + namespace ExampleLibrary { - using OxyPlot; - - using OxyPlot.Series; - - [Examples("PieSeries")] - public static class PieSeriesExamples + + public class PieViewModel { - [Example("PieSeries")] - public static PlotModel PieSeries() - { - return CreateExample(); - } - - [Example("PieSeries with inside label color")] - public static PlotModel InsideLabelColor() + private PlotModel modelP1; + public PieViewModel() { - var model = CreateExample(); - var series = (PieSeries)model.Series[0]; - series.InsideLabelColor = OxyColors.White; - return model; + modelP1 = new PlotModel { Title = "Pie Sample1" }; + + dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0 }; + + seriesP1.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = false, Fill = OxyColors.PaleVioletRed }); + seriesP1.Slices.Add(new PieSlice("Americas", 929) { IsExploded = true }); + seriesP1.Slices.Add(new PieSlice("Asia", 4157) { IsExploded = true }); + seriesP1.Slices.Add(new PieSlice("Europe", 739) { IsExploded = true }); + seriesP1.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = true }); + + modelP1.Series.Add(seriesP1); + } - - private static PlotModel CreateExample() + + public PlotModel Model1 { - var model = new PlotModel { Title = "World population by continent" }; - - var ps = new PieSeries - { - StrokeThickness = 2.0, - InsideLabelPosition = 0.8, - AngleSpan = 360, - StartAngle = 0 - }; - - // http://www.nationsonline.org/oneworld/world_population.htm - // http://en.wikipedia.org/wiki/Continent - ps.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = true }); - ps.Slices.Add(new PieSlice("Americas", 929) { IsExploded = true }); - ps.Slices.Add(new PieSlice("Asia", 4157)); - ps.Slices.Add(new PieSlice("Europe", 739) { IsExploded = true }); - ps.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = true }); - - model.Series.Add(ps); - return model; + get { return modelP1; } + set { modelP1 = value; } } + } - } - + + } .. sourcecode: VB - Create class in a file called PieViewModel.vb - Imports OxyPlot Imports OxyPlot.Series