Skip to content

Commit e0827e1

Browse files
committed
Add C# binding for Chart.IsoSurface
1 parent 9226f66 commit e0827e1

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,5 +708,80 @@ public static GenericChart.GenericChart Volume<XType, YType, ZType, ValueType, T
708708
OpacityScale: OpacityScale.ToOption(),
709709
UseDefaults: UseDefaults.ToOption()
710710
);
711+
712+
/// <summary>
713+
/// Creates a isosurface plot to visualize the volume of a 3D shape.
714+
///
715+
/// An isosurface is a surface that represents points of a constant value (e.g. pressure, temperature, velocity, density) within a volume of space.
716+
///
717+
/// Draws isosurfaces between iso-min and iso-max values with coordinates given by four 1-dimensional arrays containing the `value`, `x`, `y` and `z` of every vertex of a uniform or non-uniform 3-D grid.
718+
/// Horizontal or vertical slices, caps as well as spaceframe between iso-min and iso-max values could also be drawn using this trace.
719+
///
720+
/// This plot is very similar to the `Volume` plot. However it shows all surfaces with the same opacity.
721+
/// </summary>
722+
/// <param name="x">Sets the X coordinates of the vertices on X axis.</param>
723+
/// <param name="y">Sets the Y coordinates of the vertices on Y axis.</param>
724+
/// <param name="z">Sets the Z coordinates of the vertices on Z axis.</param>
725+
/// <param name="value">Sets the 4th dimension (value) of the vertices.</param>
726+
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
727+
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
728+
/// <param name="Opacity">Sets the opactity of the trace</param>
729+
/// <param name="Text">Sets a text associated with each datum</param>
730+
/// <param name="MultiText">Sets individual text for each datum</param>
731+
/// <param name="ColorScale">Sets the colorscale</param>
732+
/// <param name="ShowScale">Wether or not to show the colorbar/colorscale</param>
733+
/// <param name="ColorBar">Sets the colorbar</param>
734+
/// <param name="IsoMin">Sets the minimum boundary for iso-surface plot.</param>
735+
/// <param name="IsoMax">Sets the maximum boundary for iso-surface plot.</param>
736+
/// <param name="Caps">Sets the caps (color-coded surfaces on the sides of the visualization domain)</param>
737+
/// <param name="Slices">Adds Slices through the volume</param>
738+
/// <param name="Surface">Sets the surface.</param>
739+
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
740+
public static GenericChart.GenericChart IsoSurface<XType, YType, ZType, ValueType, TextType>(
741+
IEnumerable<XType> x,
742+
IEnumerable<YType> y,
743+
IEnumerable<ZType> z,
744+
IEnumerable<ValueType> value,
745+
Optional<string> Name = default,
746+
Optional<bool> ShowLegend = default,
747+
Optional<double> Opacity = default,
748+
Optional<TextType> Text = default,
749+
Optional<IEnumerable<TextType>> MultiText = default,
750+
Optional<StyleParam.Colorscale> ColorScale = default,
751+
Optional<bool> ShowScale = default,
752+
Optional<ColorBar> ColorBar = default,
753+
Optional<double> IsoMin = default,
754+
Optional<double> IsoMax = default,
755+
Optional<Caps> Caps = default,
756+
Optional<Slices> Slices = default,
757+
Optional<Surface> Surface = default,
758+
Optional<bool> UseDefaults = default
759+
)
760+
where XType : IConvertible
761+
where YType : IConvertible
762+
where ZType : IConvertible
763+
where ValueType : IConvertible
764+
where TextType : IConvertible
765+
=>
766+
Plotly.NET.Chart3D.Chart.IsoSurface<XType, YType, ZType, ValueType, TextType>(
767+
x: x,
768+
y: y,
769+
z: z,
770+
value: value,
771+
Name: Name.ToOption(),
772+
ShowLegend: ShowLegend.ToOption(),
773+
Opacity: Opacity.ToOption(),
774+
Text: Text.ToOption(),
775+
MultiText: MultiText.ToOption(),
776+
ColorScale: ColorScale.ToOption(),
777+
ShowScale: ShowScale.ToOption(),
778+
ColorBar: ColorBar.ToOption(),
779+
IsoMin: IsoMin.ToOption(),
780+
IsoMax: IsoMax.ToOption(),
781+
Caps: Caps.ToOption(),
782+
Slices: Slices.ToOption(),
783+
Surface: Surface.ToOption(),
784+
UseDefaults: UseDefaults.ToOption()
785+
);
711786
}
712787
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,18 @@ static void Main(string[] args)
375375
z: new double [] { 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2},
376376
value: new double [] { 0.8414709848, 0.6649966577, 0.4546487134, 0.6649966577, 0.3458103097,04704000269, 0.4546487134, 04704000269, -0.1892006238, 0.6649966577, 0.3458103097, 04704000269, 0.3458103097, -06853149997, -0.217228915,04704000269, -0.217228915, -0465692497, 0.4546487134, 04704000269,-0.1892006238, 04704000269, -0.217228915, -0465692497, -0.1892006238,-0465692497, 0.1236697808},
377377
ShowScale: false,
378-
Name: "value",
378+
Name: "volume",
379+
ShowLegend: true
380+
),
381+
Chart.IsoSurface<double,double,double,double,string>(
382+
x: new double [] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
383+
y: new double [] { 1, 1, 1, 1.5, 1.5, 1.5, 2, 2, 2, 1, 1, 1, 1.5, 1.5, 1.5, 2, 2, 2, 1, 1, 1, 1.5, 1.5, 1.5, 2, 2, 2 },
384+
z: new double [] { 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2, 1, 1.5, 2},
385+
value: new double [] { 0.8414709848, 0.6649966577, 0.4546487134, 0.6649966577, 0.3458103097,04704000269, 0.4546487134, 04704000269, -0.1892006238, 0.6649966577, 0.3458103097, 04704000269, 0.3458103097, -06853149997, -0.217228915,04704000269, -0.217228915, -0465692497, 0.4546487134, 04704000269,-0.1892006238, 04704000269, -0.217228915, -0465692497, -0.1892006238,-0465692497, 0.1236697808},
386+
ShowScale: false,
387+
Name: "isosurface",
379388
ShowLegend: true
380389
),
381-
Chart.Invisible(),
382390

383391
//polar traces
384392
Chart.ScatterPolar<int,int,string>(

0 commit comments

Comments
 (0)