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 Sparse Impulse Series 3D chart demo shows how to use XyzDataSeries3D and the ImpulseRenderableSeries3D to render a 3D Stem Chart.
The ImpulseRenderableSeries3D type supports data in Xyz format (individual sparse points), or Uniform grid format (every X,Z cell has a stem). The latter is more efficient but less flexible.
Impulse stems can be colored individually using the PointMetadata3D class.
The C#/WPF source code for the WPF 3D Chart Impulse (Stem) 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.SparseImpulseSeries3D"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ext="http://schemas.abtsoftware.co.uk/scichart/exampleExternals"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s3D="http://schemas.abtsoftware.co.uk/scichart3D"
xmlns:system="clr-namespace:System;assembly=mscorlib"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<UserControl.Resources>
<ext:GetTypeNameConverter x:Key="GetTypeNameConverter" />
<DataTemplate x:Key="ComboboxItemTemplate">
<TextBlock Text="{Binding ., Converter={StaticResource GetTypeNameConverter}}" />
</DataTemplate>
</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:FlyoutSeparator Background="#444" />
<ext:FlyoutMenuButton Content="SP"
Padding="0"
Style="{StaticResource FlyoutMenuButtonStyle}">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<TextBlock Text="Column Shape Type" />
<ext:FlyoutSeparator />
<ComboBox x:Name="PointMarkerCombo"
DisplayMemberPath="Name"
SelectedIndex="0"
SelectionChanged="PointMarkerCombo_OnSelectionChanged">
</ComboBox>
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
<ext:FlyoutMenuButton Content="SIZE"
Padding="0"
Style="{StaticResource FlyoutMenuButtonStyle}">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<TextBlock Text="Slide to change Column Size" />
<ext:FlyoutSeparator />
<!-- Create the size slider -->
<Slider x:Name="SizeSlider"
Margin="4"
HorizontalAlignment="Stretch"
Maximum="10"
Minimum="4"
Orientation="Horizontal"
ValueChanged="SizeSlider_OnValueChanged"
Value="4" />
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
<ext:FlyoutMenuButton Content="OP"
Padding="0"
Style="{StaticResource FlyoutMenuButtonStyle}">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<TextBlock Text="Slide to change Impulse Opacity" />
<ext:FlyoutSeparator />
<!-- Create the opacity slider -->
<Slider x:Name="OpacitySlider"
Margin="4"
HorizontalAlignment="Stretch"
Maximum="1.0"
Minimum="0.1"
Orientation="Horizontal"
ValueChanged="OpacitySlider_OnValueChanged"
Value="1.0" />
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
</ext:SciChart3DInteractionToolbar>
<s3D:SciChart3DSurface x:Name="SciChart"
Grid.Column="1"
BorderThickness="0"
WorldDimensions="200,100,200">
<s3D:SciChart3DSurface.Camera>
<s3D:Camera3D ZoomToFitOnAttach="True" />
</s3D:SciChart3DSurface.Camera>
<s3D:SciChart3DSurface.RenderableSeries>
<s3D:ImpulseRenderableSeries3D x:Name="ImpulseSeries3D"
Opacity="{Binding Source={x:Reference OpacitySlider}, Path=Value}">
<s3D:ImpulseRenderableSeries3D.PointMarker>
<s3D:SpherePointMarker3D Fill="{Binding Stroke}" Size="4.0" Opacity="1"/>
</s3D:ImpulseRenderableSeries3D.PointMarker>
</s3D:ImpulseRenderableSeries3D>
</s3D:SciChart3DSurface.RenderableSeries>
<s3D:SciChart3DSurface.XAxis>
<s3D:NumericAxis3D />
</s3D:SciChart3DSurface.XAxis>
<s3D:SciChart3DSurface.YAxis>
<s3D:NumericAxis3D />
</s3D:SciChart3DSurface.YAxis>
<s3D:SciChart3DSurface.ZAxis>
<s3D:NumericAxis3D />
</s3D:SciChart3DSurface.ZAxis>
<s3D:SciChart3DSurface.ChartModifier>
<s3D:ZoomExtentsModifier3D AutoFitRadius="True" AnimateDurationMs = "500"/>
</s3D:SciChart3DSurface.ChartModifier>
</s3D:SciChart3DSurface>
</Grid>
</UserControl>
// *************************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2022. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// SparseImpulseSeries3D.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;
using System.Windows.Controls;
using System.Windows.Media;
using SciChart.Charting3D.Model;
using SciChart.Charting3D.PointMarkers;
using SciChart.Examples.ExternalDependencies.Data;
namespace SciChart.Examples.Examples.Charts3D.CreateA3DChart
{
public partial class SparseImpulseSeries3D : UserControl
{
// A drop in replacement for System.Random which is 3x faster: https://www.codeproject.com/Articles/9187/A-fast-equivalent-for-System-Random
private readonly Random _random = new Random();
private const int Count = 15;
public SparseImpulseSeries3D()
{
InitializeComponent();
Loaded += OnLoaded;
PointMarkerCombo.Items.Add(typeof(SpherePointMarker3D));
PointMarkerCombo.Items.Add(typeof(CubePointMarker3D));
PointMarkerCombo.Items.Add(typeof(PyramidPointMarker3D));
PointMarkerCombo.Items.Add(typeof(CylinderPointMarker3D));
}
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
for (var i = 1; i < Count; i++)
{
for (var j = 1; j <= Count; j++)
{
if (i != j && i %3 == 0 && j%3 ==0)
{
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var randomColor = Color.FromArgb(0xFF, (byte) _random.Next(0, 255), (byte) _random.Next(0, 255), (byte) _random.Next(0, 255));
xyzDataSeries3D.Append(i, y, j, new PointMetadata3D(randomColor));
}
}
}
ImpulseSeries3D.DataSeries = xyzDataSeries3D;
PointMarkerCombo.SelectedIndex = 0;
}
private void PointMarkerCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ImpulseSeries3D != null && OpacitySlider != null && SizeSlider != null)
{
ImpulseSeries3D.PointMarker = (BaseMeshPointMarker3D)Activator.CreateInstance((Type)((ComboBox)sender).SelectedItem);
ImpulseSeries3D.PointMarker.Fill = ImpulseSeries3D.Stroke;
ImpulseSeries3D.PointMarker.Size = (float)SizeSlider.Value;
ImpulseSeries3D.PointMarker.Opacity = OpacitySlider.Value;
}
}
private void SizeSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (ImpulseSeries3D != null && ImpulseSeries3D.PointMarker != null)
ImpulseSeries3D.PointMarker.Size = (float)((Slider)sender).Value;
}
private void OpacitySlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (ImpulseSeries3D != null && ImpulseSeries3D.PointMarker != null)
ImpulseSeries3D.PointMarker.Opacity = ((Slider) sender).Value;
}
}
}