Skip to content

Commit 6cdf52d

Browse files
authored
Merge pull request #467 from TheKiiiing/dev
Add C# wrapper for Chart.SingleStack
2 parents d4c2ea8 + 4ebd0d0 commit 6cdf52d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Diff for: src/Plotly.NET.CSharp/ChartAPI/Chart.cs

+49
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,54 @@ public static GenericChart Grid(
7171
XSide: XSide.ToOption(),
7272
YSide: YSide.ToOption()
7373
).Invoke(gCharts);
74+
75+
///<summary>
76+
/// Creates a chart stack (a subplot grid with one column) from the input charts.
77+
/// </summary>
78+
/// <param name ="gCharts">The charts to display.</param>
79+
/// <param name ="SubPlotTitles">A collection of titles for the individual subplots.</param>
80+
/// <param name ="SubPlotTitleFont">The font of the subplot titles</param>
81+
/// <param name ="SubPlotTitleOffset">A vertical offset applied to each subplot title, moving it upwards if positive and vice versa</param>
82+
/// <param name ="SubPlots">Used for freeform grids, where some axes may be shared across subplots but others are not. Each entry should be a cartesian subplot id, like "xy" or "x3y2", or "" to leave that cell empty. You may reuse x axes within the same column, and y axes within the same row. Non-cartesian subplots and traces that support `domain` can place themselves in this grid separately using the `gridcell` attribute.</param>
83+
/// <param name ="XAxes">Used with `yaxes` when the x and y axes are shared across columns and rows. Each entry should be an y axis id like "y", "y2", etc., or "" to not put a y axis in that row. Entries other than "" must be unique. Ignored if `subplots` is present. If missing but `xaxes` is present, will generate consecutive IDs.</param>
84+
/// <param name ="YAxes">Used with `yaxes` when the x and y axes are shared across columns and rows. Each entry should be an x axis id like "x", "x2", etc., or "" to not put an x axis in that column. Entries other than "" must be unique. Ignored if `subplots` is present. If missing but `yaxes` is present, will generate consecutive IDs.</param>
85+
/// <param name ="RowOrder">Is the first row the top or the bottom? Note that columns are always enumerated from left to right.</param>
86+
/// <param name ="Pattern">If no `subplots`, `xaxes`, or `yaxes` are given but we do have `rows` and `columns`, we can generate defaults using consecutive axis IDs, in two ways: "coupled" gives one x axis per column and one y axis per row. "independent" uses a new xy pair for each cell, left-to-right across each row then iterating rows according to `roworder`.</param>
87+
/// <param name ="XGap">Horizontal space between grid cells, expressed as a fraction of the total width available to one cell. Defaults to 0.1 for coupled-axes grids and 0.2 for independent grids.</param>
88+
/// <param name ="YGap">Vertical space between grid cells, expressed as a fraction of the total height available to one cell. Defaults to 0.1 for coupled-axes grids and 0.3 for independent grids.</param>
89+
/// <param name ="Domain">Sets the domains of this grid subplot (in plot fraction). The first and last cells end exactly at the domain edges, with no grout around the edges.</param>
90+
/// <param name ="XSide">Sets where the x axis labels and titles go. "bottom" means the very bottom of the grid. "bottom plot" is the lowest plot that each x axis is used in. "top" and "top plot" are similar.</param>
91+
/// <param name ="YSide">Sets where the y axis labels and titles go. "left" means the very left edge of the grid. "left plot" is the leftmost plot that each y axis is used in. "right" and "right plot" are similar.</param>
92+
public static GenericChart SingleStack(
93+
IEnumerable<GenericChart> gCharts,
94+
Optional<IEnumerable<string>> SubPlotTitles = default,
95+
Optional<Font> SubPlotTitleFont = default,
96+
Optional<double> SubPlotTitleOffset = default,
97+
Optional<Tuple<StyleParam.LinearAxisId, StyleParam.LinearAxisId>[][]> SubPlots = default,
98+
Optional<StyleParam.LinearAxisId[]> XAxes = default,
99+
Optional<StyleParam.LinearAxisId[]> YAxes = default,
100+
Optional<StyleParam.LayoutGridRowOrder> RowOrder = default,
101+
Optional<StyleParam.LayoutGridPattern> Pattern = default,
102+
Optional<double> XGap = default,
103+
Optional<double> YGap = default,
104+
Optional<Domain> Domain = default,
105+
Optional<StyleParam.LayoutGridXSide> XSide = default,
106+
Optional<StyleParam.LayoutGridYSide> YSide = default
107+
) =>
108+
Plotly.NET.Chart.SingleStack<IEnumerable<string>, IEnumerable<GenericChart>>(
109+
SubPlotTitles: SubPlotTitles.ToOption(),
110+
SubPlotTitleFont: SubPlotTitleFont.ToOption(),
111+
SubPlotTitleOffset: SubPlotTitleOffset.ToOption(),
112+
SubPlots: SubPlots.ToOption(),
113+
XAxes: XAxes.ToOption(),
114+
YAxes: YAxes.ToOption(),
115+
RowOrder: RowOrder.ToOption(),
116+
Pattern: Pattern.ToOption(),
117+
XGap: XGap.ToOption(),
118+
YGap: YGap.ToOption(),
119+
Domain: Domain.ToOption(),
120+
XSide: XSide.ToOption(),
121+
YSide: YSide.ToOption()
122+
).Invoke(gCharts);
74123
}
75124
}

0 commit comments

Comments
 (0)