Skip to content

Commit 38dd73d

Browse files
committed
Add C# bindings for Chart.SplineArea + Chart.StackedArea
1 parent 551dfce commit 38dd73d

File tree

2 files changed

+203
-0
lines changed

2 files changed

+203
-0
lines changed

src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,194 @@ public static GenericChart.GenericChart Area<XType, YType, TextType>(
695695
UseDefaults: UseDefaults.ToOption()
696696
);
697697

698+
/// <summary>Creates a Spline area chart, which uses a smoothed Line plotted between the given datums in a 2D space, additionally colouring the area between the line and the Y Axis.</summary>
699+
/// <param name="x">Sets the x coordinates of the plotted data.</param>
700+
/// <param name="y">Sets the y coordinates of the plotted data.</param>
701+
/// <param name="ShowMarkers">Wether to show markers for the individual data points</param>
702+
/// <param name="Smoothing">Sets the amount of smoothing. "0" corresponds to no smoothing (equivalent to a "linear" shape). Use values between 0. and 1.3</param>
703+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
704+
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
705+
/// <param name="Opacity">Sets the opactity of the trace</param>
706+
/// <param name="MultiOpacity">Sets the opactity of individual datum markers</param>
707+
/// <param name="Text">Sets a text associated with each datum</param>
708+
/// <param name="MultiText">Sets individual text for each datum</param>
709+
/// <param name="TextPosition">Sets the position of text associated with each datum</param>
710+
/// <param name="MultiTextPosition">Sets the position of text associated with individual datum</param>
711+
/// <param name="MarkerColor">Sets the color of the marker</param>
712+
/// <param name="MarkerColorScale">Sets the colorscale of the marker</param>
713+
/// <param name="MarkerOutline">Sets the outline of the marker</param>
714+
/// <param name="MarkerSymbol">Sets the marker symbol for each datum</param>
715+
/// <param name="MultiMarkerSymbol">Sets the marker symbol for each individual datum</param>
716+
/// <param name="Marker">Sets the marker (use this for more finegrained control than the other marker-associated arguments)</param>
717+
/// <param name="LineColor">Sets the color of the line</param>
718+
/// <param name="LineColorScale">Sets the colorscale of the line</param>
719+
/// <param name="LineWidth">Sets the width of the line</param>
720+
/// <param name="LineDash">sets the drawing style of the line</param>
721+
/// <param name="Line">Sets the line (use this for more finegrained control than the other line-associated arguments)</param>
722+
/// <param name="StackGroup">Set several traces (on the same subplot) to the same stackgroup in order to add their y values (or their x values if `Orientation` is Horizontal). Stacking also turns `fill` on by default and sets the default `mode` to "lines" irrespective of point count. ou can only stack on a numeric (linear or log) axis. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order</param>
723+
/// <param name="Orientation">Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used.</param>
724+
/// <param name="GroupNorm">Sets the normalization for the sum of this `stackgroup. Only relevant when `stackgroup` is used, and only the first `groupnorm` found in the `stackgroup` will be used</param>
725+
/// <param name="FillColor">ets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.</param>
726+
/// <param name="UseWebGL">If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once.</param>
727+
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
728+
public static GenericChart.GenericChart SplineArea<XType, YType, TextType>(
729+
IEnumerable<XType> x,
730+
IEnumerable<YType> y,
731+
Optional<bool> ShowMarkers = default,
732+
Optional<double> Smoothing = default,
733+
Optional<string> Name = default,
734+
Optional<bool> ShowLegend = default,
735+
Optional<double> Opacity = default,
736+
Optional<IEnumerable<double>> MultiOpacity = default,
737+
Optional<TextType> Text = default,
738+
Optional<IEnumerable<TextType>> MultiText = default,
739+
Optional<StyleParam.TextPosition> TextPosition = default,
740+
Optional<IEnumerable<StyleParam.TextPosition>> MultiTextPosition = default,
741+
Optional<Color> MarkerColor = default,
742+
Optional<StyleParam.Colorscale> MarkerColorScale = default,
743+
Optional<Line> MarkerOutline = default,
744+
Optional<StyleParam.MarkerSymbol> MarkerSymbol = default,
745+
Optional<IEnumerable<StyleParam.MarkerSymbol>> MultiMarkerSymbol = default,
746+
Optional<Marker> Marker = default,
747+
Optional<Color> LineColor = default,
748+
Optional<StyleParam.Colorscale> LineColorScale = default,
749+
Optional<double> LineWidth = default,
750+
Optional<StyleParam.DrawingStyle> LineDash = default,
751+
Optional<Line> Line = default,
752+
Optional<string> StackGroup = default,
753+
Optional<StyleParam.Orientation> Orientation = default,
754+
Optional<StyleParam.GroupNorm> GroupNorm = default,
755+
Optional<Color> FillColor = default,
756+
Optional<bool> UseWebGL = default,
757+
Optional<bool> UseDefaults = default
758+
)
759+
where XType : IConvertible
760+
where YType : IConvertible
761+
where TextType : IConvertible
762+
=>
763+
Plotly.NET.Chart2D.Chart.SplineArea<XType, YType, TextType>(
764+
x: x,
765+
y: y,
766+
ShowMarkers: ShowMarkers.ToOption(),
767+
Smoothing: Smoothing.ToOption(),
768+
Name: Name.ToOption(),
769+
ShowLegend: ShowLegend.ToOption(),
770+
Opacity: Opacity.ToOption(),
771+
MultiOpacity: MultiOpacity.ToOption(),
772+
Text: Text.ToOption(),
773+
MultiText: MultiText.ToOption(),
774+
TextPosition: TextPosition.ToOption(),
775+
MultiTextPosition: MultiTextPosition.ToOption(),
776+
MarkerColor: MarkerColor.ToOption(),
777+
MarkerColorScale: MarkerColorScale.ToOption(),
778+
MarkerOutline: MarkerOutline.ToOption(),
779+
MarkerSymbol: MarkerSymbol.ToOption(),
780+
MultiMarkerSymbol: MultiMarkerSymbol.ToOption(),
781+
Marker: Marker.ToOption(),
782+
LineColor: LineColor.ToOption(),
783+
LineColorScale: LineColorScale.ToOption(),
784+
LineWidth: LineWidth.ToOption(),
785+
LineDash: LineDash.ToOption(),
786+
Line: Line.ToOption(),
787+
StackGroup: StackGroup.ToOption(),
788+
Orientation: Orientation.ToOption(),
789+
GroupNorm: GroupNorm.ToOption(),
790+
FillColor: FillColor.ToOption(),
791+
UseWebGL: UseWebGL.ToOption(),
792+
UseDefaults: UseDefaults.ToOption()
793+
);
794+
795+
/// <summary> Creates a stacked Area chart, which uses a Line plotted between the given datums in a 2D space, additionally colouring the area between the line and the Y Axis. Multiple Charts of this type are stacked on top of each others y dimensions</summary>
796+
/// <param name="x">Sets the x coordinates of the plotted data.</param>
797+
/// <param name="y">Sets the y coordinates of the plotted data.</param>
798+
/// <param name="ShowMarkers">Wether to show markers for the individual data points</param>
799+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
800+
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
801+
/// <param name="Opacity">Sets the opactity of the trace</param>
802+
/// <param name="MultiOpacity">Sets the opactity of individual datum markers</param>
803+
/// <param name="Text">Sets a text associated with each datum</param>
804+
/// <param name="MultiText">Sets individual text for each datum</param>
805+
/// <param name="TextPosition">Sets the position of text associated with each datum</param>
806+
/// <param name="MultiTextPosition">Sets the position of text associated with individual datum</param>
807+
/// <param name="MarkerColor">Sets the color of the marker</param>
808+
/// <param name="MarkerColorScale">Sets the colorscale of the marker</param>
809+
/// <param name="MarkerOutline">Sets the outline of the marker</param>
810+
/// <param name="MarkerSymbol">Sets the marker symbol for each datum</param>
811+
/// <param name="MultiMarkerSymbol">Sets the marker symbol for each individual datum</param>
812+
/// <param name="Marker">Sets the marker (use this for more finegrained control than the other marker-associated arguments)</param>
813+
/// <param name="LineColor">Sets the color of the line</param>
814+
/// <param name="LineColorScale">Sets the colorscale of the line</param>
815+
/// <param name="LineWidth">Sets the width of the line</param>
816+
/// <param name="LineDash">sets the drawing style of the line</param>
817+
/// <param name="Line">Sets the line (use this for more finegrained control than the other line-associated arguments)</param>
818+
/// <param name="Orientation">Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used.</param>
819+
/// <param name="GroupNorm">Sets the normalization for the sum of this `stackgroup. Only relevant when `stackgroup` is used, and only the first `groupnorm` found in the `stackgroup` will be used</param>
820+
/// <param name="FillColor">ets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.</param>
821+
/// <param name="UseWebGL">If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once.</param>
822+
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
823+
public static GenericChart.GenericChart StackedArea<XType, YType, TextType>(
824+
IEnumerable<XType> x,
825+
IEnumerable<YType> y,
826+
Optional<bool> ShowMarkers = default,
827+
Optional<string> Name = default,
828+
Optional<bool> ShowLegend = default,
829+
Optional<double> Opacity = default,
830+
Optional<IEnumerable<double>> MultiOpacity = default,
831+
Optional<TextType> Text = default,
832+
Optional<IEnumerable<TextType>> MultiText = default,
833+
Optional<StyleParam.TextPosition> TextPosition = default,
834+
Optional<IEnumerable<StyleParam.TextPosition>> MultiTextPosition = default,
835+
Optional<Color> MarkerColor = default,
836+
Optional<StyleParam.Colorscale> MarkerColorScale = default,
837+
Optional<Line> MarkerOutline = default,
838+
Optional<StyleParam.MarkerSymbol> MarkerSymbol = default,
839+
Optional<IEnumerable<StyleParam.MarkerSymbol>> MultiMarkerSymbol = default,
840+
Optional<Marker> Marker = default,
841+
Optional<Color> LineColor = default,
842+
Optional<StyleParam.Colorscale> LineColorScale = default,
843+
Optional<double> LineWidth = default,
844+
Optional<StyleParam.DrawingStyle> LineDash = default,
845+
Optional<Line> Line = default,
846+
Optional<StyleParam.Orientation> Orientation = default,
847+
Optional<StyleParam.GroupNorm> GroupNorm = default,
848+
Optional<Color> FillColor = default,
849+
Optional<bool> UseWebGL = default,
850+
Optional<bool> UseDefaults = default
851+
)
852+
where XType : IConvertible
853+
where YType : IConvertible
854+
where TextType : IConvertible
855+
=>
856+
Plotly.NET.Chart2D.Chart.StackedArea<XType, YType, TextType>(
857+
x: x,
858+
y: y,
859+
ShowMarkers: ShowMarkers.ToOption(),
860+
Name: Name.ToOption(),
861+
ShowLegend: ShowLegend.ToOption(),
862+
Opacity: Opacity.ToOption(),
863+
MultiOpacity: MultiOpacity.ToOption(),
864+
Text: Text.ToOption(),
865+
MultiText: MultiText.ToOption(),
866+
TextPosition: TextPosition.ToOption(),
867+
MultiTextPosition: MultiTextPosition.ToOption(),
868+
MarkerColor: MarkerColor.ToOption(),
869+
MarkerColorScale: MarkerColorScale.ToOption(),
870+
MarkerOutline: MarkerOutline.ToOption(),
871+
MarkerSymbol: MarkerSymbol.ToOption(),
872+
MultiMarkerSymbol: MultiMarkerSymbol.ToOption(),
873+
Marker: Marker.ToOption(),
874+
LineColor: LineColor.ToOption(),
875+
LineColorScale: LineColorScale.ToOption(),
876+
LineWidth: LineWidth.ToOption(),
877+
LineDash: LineDash.ToOption(),
878+
Line: Line.ToOption(),
879+
Orientation: Orientation.ToOption(),
880+
GroupNorm: GroupNorm.ToOption(),
881+
FillColor: FillColor.ToOption(),
882+
UseWebGL: UseWebGL.ToOption(),
883+
UseDefaults: UseDefaults.ToOption()
884+
);
885+
698886
/// <summary>
699887
/// Creates a bar chart, with bars plotted horizontally
700888
///

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ static void Main(string[] args)
7272
x: new int [] { 1, 2},
7373
y: new int [] { 3, 1},
7474
Name: "area"
75+
),
76+
Chart.SplineArea<int,int,string>(
77+
x: new int [] { 3, 4, 5},
78+
y: new int [] { 3, 1, 4},
79+
Name: "splinearea"
80+
),
81+
Chart.StackedArea<int,int,string>(
82+
x: new int [] { 6, 7},
83+
y: new int [] { 3, 1},
84+
Name: "stacked area 1"
85+
),
86+
Chart.StackedArea<int,int,string>(
87+
x: new int [] { 6, 7},
88+
y: new int [] { 3, 2},
89+
Name: "stacked area 2"
7590
)
7691
}
7792
).WithTraceInfo(

0 commit comments

Comments
 (0)