Skip to content

Commit 3219e44

Browse files
authored
Merge pull request #294 from plotly/csharp-layer
2 parents b8f1d88 + 3e8023e commit 3219e44

19 files changed

+1713
-46
lines changed

Plotly.NET.sln

+18
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Plotly.NET.ImageExport.Test
150150
EndProject
151151
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "build\build.fsproj", "{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}"
152152
EndProject
153+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plotly.NET.CSharp", "src\Plotly.NET.CSharp\Plotly.NET.CSharp.csproj", "{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}"
154+
EndProject
155+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plotly.NET.CSharp.Tests", "tests\Plotly.NET.CSharp.Tests\Plotly.NET.CSharp.Tests.csproj", "{4C24BA53-F41C-4110-AD7A-28143DCF671E}"
156+
EndProject
153157
Global
154158
GlobalSection(SolutionConfigurationPlatforms) = preSolution
155159
Debug|Any CPU = Debug|Any CPU
@@ -211,6 +215,18 @@ Global
211215
{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Dotnet|Any CPU.Build.0 = Debug|Any CPU
212216
{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
213217
{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Release|Any CPU.Build.0 = Release|Any CPU
218+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
219+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
220+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Dotnet|Any CPU.ActiveCfg = Debug|Any CPU
221+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Dotnet|Any CPU.Build.0 = Debug|Any CPU
222+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
223+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Release|Any CPU.Build.0 = Release|Any CPU
224+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
225+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Debug|Any CPU.Build.0 = Debug|Any CPU
226+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Dotnet|Any CPU.ActiveCfg = Debug|Any CPU
227+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Dotnet|Any CPU.Build.0 = Debug|Any CPU
228+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Release|Any CPU.ActiveCfg = Release|Any CPU
229+
{4C24BA53-F41C-4110-AD7A-28143DCF671E}.Release|Any CPU.Build.0 = Release|Any CPU
214230
EndGlobalSection
215231
GlobalSection(SolutionProperties) = preSolution
216232
HideSolutionNode = FALSE
@@ -228,6 +244,8 @@ Global
228244
{26539796-0C9D-4856-8584-B58BE32CC495} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8}
229245
{55A461C3-8018-4020-B16E-D6005BDFCAED} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8}
230246
{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD} = {7C6D08E7-3EAC-4335-8F4B-252C193C27C9}
247+
{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26} = {0E87E47E-9EDC-4525-AF72-F0E139D54236}
248+
{4C24BA53-F41C-4110-AD7A-28143DCF671E} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8}
231249
EndGlobalSection
232250
GlobalSection(ExtensibilityGlobals) = postSolution
233251
SolutionGuid = {7177F1E1-341C-48AB-9864-6B525FFF7633}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Plotly.NET;
7+
using Plotly.NET.LayoutObjects;
8+
using Plotly.NET.TraceObjects;
9+
10+
namespace Plotly.NET.CSharp
11+
{
12+
public static partial class Chart
13+
{
14+
public static GenericChart.GenericChart Combine(IEnumerable<GenericChart.GenericChart> gCharts) => Plotly.NET.Chart.Combine(gCharts);
15+
16+
17+
public static GenericChart.GenericChart Invisible() => Plotly.NET.Chart.Invisible();
18+
19+
/// <summary>
20+
/// Creates a subplot grid with the given dimensions (nRows x nCols) for the input charts.
21+
/// </summary>
22+
/// <param name ="gCharts">The charts to display on the grid.</param>
23+
/// <param name ="nRows">The number of rows in the grid. If you provide a 2D `subplots` array or a `yaxes` array, its length is used as the default. But it's also possible to have a different length, if you want to leave a row at the end for non-cartesian subplots.</param>
24+
/// <param name ="nCols">The number of columns in the grid. If you provide a 2D `subplots` array, the length of its longest row is used as the default. If you give an `xaxes` array, its length is used as the default. But it's also possible to have a different length, if you want to leave a row at the end for non-cartesian subplots.</param>
25+
/// <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>
26+
/// <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>
27+
/// <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>
28+
/// <param name ="RowOrder">Is the first row the top or the bottom? Note that columns are always enumerated from left to right.</param>
29+
/// <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>
30+
/// <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>
31+
/// <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>
32+
/// <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>
33+
/// <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>
34+
/// <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>
35+
public static GenericChart.GenericChart Grid(
36+
IEnumerable<GenericChart.GenericChart> gCharts,
37+
int nRows,
38+
int nCols,
39+
Tuple<StyleParam.LinearAxisId, StyleParam.LinearAxisId>[][]? SubPlots = null,
40+
StyleParam.LinearAxisId[]? XAxes = null,
41+
StyleParam.LinearAxisId[]? YAxes = null,
42+
StyleParam.LayoutGridRowOrder? RowOrder = null,
43+
StyleParam.LayoutGridPattern? Pattern = null,
44+
double? XGap = null,
45+
double? YGap = null,
46+
Domain? Domain = null,
47+
StyleParam.LayoutGridXSide? XSide = null,
48+
StyleParam.LayoutGridYSide? YSide = null
49+
) =>
50+
Plotly.NET.Chart.Grid<IEnumerable<GenericChart.GenericChart>>(
51+
nRows: nRows,
52+
nCols: nCols,
53+
SubPlots: Helpers.ToOption(SubPlots),
54+
XAxes: Helpers.ToOption(XAxes),
55+
YAxes: Helpers.ToOption(YAxes),
56+
RowOrder: Helpers.ToOption(RowOrder),
57+
Pattern: Helpers.ToOption(Pattern),
58+
XGap: Helpers.ToOptionV(XGap),
59+
YGap: Helpers.ToOptionV(YGap),
60+
Domain: Helpers.ToOption(Domain),
61+
XSide: Helpers.ToOption(XSide),
62+
YSide: Helpers.ToOption(YSide)
63+
).Invoke(gCharts);
64+
}
65+
}

0 commit comments

Comments
 (0)