SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
SciChart WPF ships with hundreds of WPF Chart Examples which you can browse, play with, view the source-code and even export each WPF Chart Example to a stand-alone Visual Studio solution. All of this is possible with the new and improved SciChart WPF Examples Suite, which ships as part of the SciChart WPF SDK.
The Cylindroid 3D chart demo shows how to use CylindroidDataSeries3D and the FreeSurfaceRenderableSeries3D to render 3d ellipsoid.
FreeSurfaceRenderableSeries3D allows you to create all kinds of shapes, including Sphere, Cylinder, Disc and free-form mesh shapes, and overlay heightmap, colormap (palette) and contours. Find examples of other shapes in the same section here or visit the web site for more information.
Palette Mode drop-down menu demonstrates different modes of the data representation.
The C#/WPF source code for the WPF 3D Simple Cylindroid Chart Example example is included below (Scroll down!).
Did you know you can also view the source code from one of the following sources as well?
<UserControl x:Class="SciChart.Examples.Examples.Charts3D.CreateA3DChart.CreateACylindroidMesh3DChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ext="http://schemas.abtsoftware.co.uk/scichart/exampleExternals"
xmlns:s3D="http://schemas.abtsoftware.co.uk/scichart3D"
mc:Ignorable="d"
d:DesignHeight="400"
d:DesignWidth="600">
<UserControl.Resources>
<s3D:GradientColorPalette x:Key="HeightColorMap" ContourColor="Black" ContourStrokeThickness="2.0">
<s3D:GradientColorPalette.GradientStops>
<GradientStop Offset="1" Color="DarkRed"/>
<GradientStop Offset="0.9" Color="Red"/>
<GradientStop Offset="0.7" Color="Yellow"/>
<GradientStop Offset="0.5" Color="GreenYellow"/>
<GradientStop Offset="0.3" Color="Cyan"/>
<GradientStop Offset="0.1" Color="Blue"/>
<GradientStop Offset="0.0" Color="#1D2C6B"/>
</s3D:GradientColorPalette.GradientStops>
</s3D:GradientColorPalette>
<ext:EnumValueToStringConverter x:Key="SelectedEnumValueConverter" />
<ext:LinearToLogarithmicValueConverter x:Key="LinearToLogarithmicValueConverter"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- The SciChart3DInteractionToolbar adds rotate, orbit, zoom, pan, zoom extents functionality -->
<!-- to the chart and is included for example purposes. -->
<!-- If you wish to know how to zoom and pan a 3D chart then do a search for Zoom Pan in the Examples suite! -->
<ext:SciChart3DInteractionToolbar TargetSurface="{Binding Source={x:Reference Name=sciChart}}" >
<ext:FlyoutMenuButton Style="{StaticResource FlyoutMenuButtonStyle}"
Content="CTRL"
FontSize="10"
Padding="0">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel Orientation="Vertical" MinWidth="150">
<!-- Checkboxes to decide how the mesh should be drawn -->
<TextBlock FontSize="12" Text="Draw Mesh As" />
<ComboBox ItemsSource="{Binding Source={ext:EnumValues {x:Type s3D:DrawMeshAs}}}" SelectedItem="{Binding DrawMeshAs, Source={x:Reference cylindroidMeshRenderableSeries}, Mode=TwoWay, Converter={StaticResource SelectedEnumValueConverter}}" />
<!-- Checkbox for Draw Back Side on or off -->
<TextBlock FontSize="12" Text="Back Side" />
<CheckBox FontSize="12" Margin="4" x:Name="CheckDrawSkirt" Content="Draw Back Side?" IsChecked="{Binding DrawBackSide, Source={x:Reference cylindroidMeshRenderableSeries}, Mode=TwoWay}"/>
<ext:FlyoutSeparator/>
<!-- Create the opacity slider -->
<TextBlock FontSize="12" Text="Opacity" />
<Slider Minimum="0.1" Maximum="1.0" x:Name="opacitySlider" Value="0.9" Margin="4" Orientation="Horizontal" HorizontalAlignment="Stretch"/>
<TextBlock FontSize="12" Text="Lighting Factor" />
<Slider Minimum="0.0" Maximum="1.0" x:Name="lightingFactorSlider" Value="0.8" Margin="4" Orientation="Horizontal" HorizontalAlignment="Stretch"/>
<TextBlock FontSize="12" Text="Shininess" />
<Slider Minimum="0" Maximum="11" x:Name="shininessSlider" Margin="4" Orientation="Horizontal" HorizontalAlignment="Stretch"/>
<TextBlock FontSize="12" Text="Specular Strength" />
<Slider Minimum="0.1" Maximum="5.0" x:Name="specularStrengthSlider" Value="1.0" Margin="4" Orientation="Horizontal" HorizontalAlignment="Stretch"/>
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
<ext:FlyoutSeparator Background="#444" />
<ext:FlyoutMenuButton Content="PM"
Padding="0"
Style="{StaticResource FlyoutMenuButtonStyle}">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<!-- Create the palette mode -->
<TextBlock FontSize="12" Text="Palette Mode" />
<ComboBox SelectionChanged="PaletteModeComboBox_OnSelectionChanged">
<ComboBoxItem IsSelected="True">Radial</ComboBoxItem>
<ComboBoxItem>Axial</ComboBoxItem>
<ComboBoxItem>Azimuthal</ComboBoxItem>
<ComboBoxItem>Polar</ComboBoxItem>
</ComboBox>
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
</ext:SciChart3DInteractionToolbar>
<s3D:SciChart3DSurface x:Name="sciChart" Grid.Column="1" WorldDimensions="200,200,200" BorderThickness="0">
<s3D:SciChart3DSurface.Camera>
<s3D:Camera3D ZoomToFitOnAttach="True"/>
</s3D:SciChart3DSurface.Camera>
<s3D:SciChart3DSurface.RenderableSeries>
<s3D:FreeSurfaceRenderableSeries3D x:Name="cylindroidMeshRenderableSeries"
DrawMeshAs="SolidWireFrame"
Stroke="#77228B22"
ContourInterval="0.1"
ContourStroke="#77228B22"
StrokeThickness="2.0"
LightingFactor="{Binding Source={x:Reference Name=lightingFactorSlider}, Path=Value, Mode=TwoWay}"
Opacity="{Binding Source={x:Reference Name=opacitySlider}, Path=Value, Mode=TwoWay}"
MeshColorPalette="{StaticResource HeightColorMap}"
Shininess="{Binding Source={x:Reference Name=shininessSlider}, Path=Value, Mode=TwoWay, Converter={StaticResource LinearToLogarithmicValueConverter}}"
SpecularStrength="{Binding Source={x:Reference Name=specularStrengthSlider}, Path=Value, Mode=TwoWay}"
PaletteMinimum="3.0, 0.0, 0.0" PaletteMaximum="4.0, 0.0, 0.0" />
</s3D:SciChart3DSurface.RenderableSeries>
<s3D:SciChart3DSurface.XAxis>
<s3D:NumericAxis3D NegativeSideClipping="None" PositiveSideClipping="None" />
</s3D:SciChart3DSurface.XAxis>
<s3D:SciChart3DSurface.YAxis>
<s3D:NumericAxis3D />
</s3D:SciChart3DSurface.YAxis>
<s3D:SciChart3DSurface.ZAxis>
<s3D:NumericAxis3D NegativeSideClipping="None" PositiveSideClipping="None" />
</s3D:SciChart3DSurface.ZAxis>
</s3D:SciChart3DSurface>
</Grid>
</UserControl>
// *************************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2021. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// CreateACylindroidMesh3DChart.xaml.cs is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied.
// *************************************************************************************
using System;
using System.Windows.Controls;
using SciChart.Charting3D;
using SciChart.Charting3D.Model;
using SciChart.Charting3D.RenderableSeries;
namespace SciChart.Examples.Examples.Charts3D.CreateA3DChart
{
public partial class CreateACylindroidMesh3DChart : UserControl
{
public CreateACylindroidMesh3DChart()
{
InitializeComponent();
int countU = 40;
int countV = 20;
var meshDataSeries = new CylindroidDataSeries3D<double>(countU, countV)
{
SeriesName = "Cylindroid Mesh",
A = 3,
B = 3,
H = 7
};
var random = new Random(0);
for (var u = 0; u < countU; u++)
{
for (int v = 0; v < countV; v++)
{
var weight = 1.0f - Math.Abs(v / (float) countV * 2.0f - 1.0f);
var offset = (float)random.NextDouble();
meshDataSeries[v, u] = offset * weight;
}
}
cylindroidMeshRenderableSeries.DataSeries = meshDataSeries;
cylindroidMeshRenderableSeries.DrawBackSide = true;
}
private void PaletteModeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cylindroidMeshRenderableSeries == null)
return;
switch (((ContentControl)e.AddedItems[0]).Content.ToString())
{
case "Radial":
cylindroidMeshRenderableSeries.PaletteMinMaxMode = FreeSurfacePaletteMinMaxMode.Relative;
cylindroidMeshRenderableSeries.PaletteMinimum = new Vector3(3.0f, 0.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteMaximum = new Vector3(4.0f, 0.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteRadialFactor = 1.0;
cylindroidMeshRenderableSeries.PaletteAxialFactor = new Vector3(0.0f, 0.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteAzimuthalFactor = 0.0;
cylindroidMeshRenderableSeries.PalettePolarFactor = 0.0;
break;
case "Axial":
cylindroidMeshRenderableSeries.PaletteMinMaxMode = FreeSurfacePaletteMinMaxMode.Absolute;
cylindroidMeshRenderableSeries.PaletteMinimum = new Vector3(0.0f, -4.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteMaximum = new Vector3(0.0f, 4.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteRadialFactor = 0.0;
cylindroidMeshRenderableSeries.PaletteAxialFactor = new Vector3(0.0f, 1.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteAzimuthalFactor = 0.0;
cylindroidMeshRenderableSeries.PalettePolarFactor = 0.0;
break;
case "Azimuthal":
cylindroidMeshRenderableSeries.PaletteRadialFactor = 0.0;
cylindroidMeshRenderableSeries.PaletteAxialFactor = new Vector3(0.0f, 0.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteAzimuthalFactor = 1.0;
cylindroidMeshRenderableSeries.PalettePolarFactor = 0.0;
break;
case "Polar":
cylindroidMeshRenderableSeries.PaletteRadialFactor = 0.0;
cylindroidMeshRenderableSeries.PaletteAxialFactor = new Vector3(0.0f, 0.0f, 0.0f);
cylindroidMeshRenderableSeries.PaletteAzimuthalFactor = 0.0;
cylindroidMeshRenderableSeries.PalettePolarFactor = 1.0;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}