Skip to content

Commit 104ce55

Browse files
committed
Add Chart.Pie C# binding
1 parent b8e50f5 commit 104ce55

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using Plotly.NET;
2+
using Plotly.NET.LayoutObjects;
3+
using Plotly.NET.TraceObjects;
4+
5+
6+
namespace Plotly.NET.CSharp
7+
{
8+
public static partial class Chart
9+
{
10+
public static GenericChart.GenericChart Pie<ValuesType, LabelsType, TextType>(
11+
IEnumerable<ValuesType> values,
12+
string? Name = null,
13+
bool? ShowLegend = null,
14+
double? Opacity = null,
15+
IEnumerable<double>? MultiOpacity = null,
16+
IEnumerable<LabelsType>? Labels = null,
17+
double? Pull = null,
18+
IEnumerable<double>? MultiPull = null,
19+
TextType? Text = null,
20+
IEnumerable<TextType>? MultiText = null,
21+
StyleParam.TextPosition? TextPosition = null,
22+
IEnumerable<StyleParam.TextPosition>? MultiTextPosition = null,
23+
IEnumerable<Color>? SectionColors = null,
24+
Color? SectionOutlineColor = null,
25+
double? SectionOutlineWidth = null,
26+
IEnumerable<double>? SectionOutlineMultiWidth = null,
27+
Line? SectionOutline = null,
28+
Marker? Marker = null,
29+
StyleParam.TextInfo? TextInfo = null,
30+
StyleParam.Direction? Direction = null,
31+
double? Hole = null,
32+
double? Rotation = null,
33+
bool? Sort = null,
34+
bool? UseDefaults = null
35+
)
36+
where ValuesType : IConvertible
37+
where LabelsType : IConvertible
38+
where TextType : class, IConvertible
39+
=>
40+
Plotly.NET.ChartDomain.Chart.Pie<ValuesType, LabelsType, TextType>(
41+
values: values,
42+
Name: Name.ToOption(),
43+
ShowLegend: ShowLegend.ToOptionV(),
44+
Opacity: Opacity.ToOptionV(),
45+
MultiOpacity: MultiOpacity.ToOption(),
46+
Labels: Labels.ToOption(),
47+
Pull: Pull.ToOptionV(),
48+
MultiPull: MultiPull.ToOption(),
49+
Text: Text.ToOption(),
50+
MultiText: MultiText.ToOption(),
51+
TextPosition: TextPosition.ToOption(),
52+
MultiTextPosition: MultiTextPosition.ToOption(),
53+
SectionColors: SectionColors.ToOption(),
54+
SectionOutlineColor: SectionOutlineColor.ToOption(),
55+
SectionOutlineWidth: SectionOutlineWidth.ToOptionV(),
56+
SectionOutlineMultiWidth: SectionOutlineMultiWidth.ToOption(),
57+
SectionOutline: SectionOutline.ToOption(),
58+
Marker: Marker.ToOption(),
59+
TextInfo: TextInfo.ToOption(),
60+
Direction: Direction.ToOption(),
61+
Hole: Hole.ToOptionV(),
62+
Rotation: Rotation.ToOptionV(),
63+
Sort: Sort.ToOptionV(),
64+
UseDefaults: UseDefaults.ToOptionV()
65+
);
66+
67+
}
68+
}

tests/Plotly.NET.Tests.CSharpConsole/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Program
1010
static void Main(string[] args)
1111
{
1212
Chart.Grid(
13-
nRows: 6,
13+
nRows: 7,
1414
nCols: 3,
1515
gCharts:
1616
new GenericChart []
@@ -65,6 +65,12 @@ static void Main(string[] args)
6565
),
6666
Chart.Invisible(),
6767
Chart.Invisible(),
68+
Chart.Pie<double,string,string>(
69+
values: new double [] {1,2,3,4},
70+
Labels: new string [] {"soos", "saas", "fiif", "leel"}
71+
),
72+
Chart.Invisible(),
73+
Chart.Invisible(),
6874
}
6975
)
7076
.WithSize(750,2000)

0 commit comments

Comments
 (0)