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.
Generates a Ternary Scatter chart in code. The TernaryScatterRenderableSeries can be used to render an XyzDataSeries.
The scatter chart uses the PointMarker API to define the marker shape and size. This can be customized in code or you can create your own Point-Markers using our SpritePointMarker or BasePointMarker type.
Documentation Links
– What is a Ternary Chart?
– The Ternary Scatter Series type
The C#/WPF source code for the WPF Scatter Series Ternary Chart 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.CreateTernaryChart.ScatterSeriesTernaryChartExampleView"
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:local="clr-namespace:SciChart.Examples.Examples.CreateTernaryChart"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/SciChart.Examples.ExternalDependencies;component/Resources/Styles/MergedResources.xaml" />
<ResourceDictionary Source="/SciChart.Examples.ExternalDependencies;component/Resources/Styles/ToolbarButtonsCommon.xaml" />
</ResourceDictionary.MergedDictionaries>
<ext:EnumValueToStringConverter x:Key="SelectedEnumValueConverter" />
<Style x:Key="HintDataItemsTooltipTernaryStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="1" />
</Style>
<DataTemplate x:Key="TooltipTernaryModifierLabelTemplate" DataType="s:TernarySeriesInfo">
<StackPanel Orientation="Vertical">
<TextBlock Style="{StaticResource HintDataItemsTooltipTernaryStyle}"
Text="{Binding SeriesName, StringFormat='{}{0}'}"
TextDecorations="Underline" />
<TextBlock Style="{StaticResource HintDataItemsTooltipTernaryStyle}" Text="{Binding FormattedXValue, StringFormat='{}Earth: {0}'}" />
<TextBlock Style="{StaticResource HintDataItemsTooltipTernaryStyle}" Text="{Binding FormattedYValue, StringFormat='{}Fire: {0}'}" />
<TextBlock Style="{StaticResource HintDataItemsTooltipTernaryStyle}" Text="{Binding FormattedZValue, StringFormat='{}Air: {0}'}" />
</StackPanel>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- This toolbar adds cursor, tooltip, legend and theme change functionality -->
<Border Panel.ZIndex="9999"
Background="#FF232426"
BorderBrush="#323539"
BorderThickness="0,0,2,0">
<WrapPanel HorizontalAlignment="Left" Orientation="Vertical">
<ToggleButton x:Name="cursorModButton"
HorizontalAlignment="Left"
Content="Cursor"
IsChecked="{Binding Source={x:Reference Name=cursorTernaryModifier}, Path=IsEnabled, Mode=TwoWay}"
Style="{StaticResource CursorTernaryButtonStyle}"
ToolTipService.ToolTip="Cursor Ternary Modifier" />
<ToggleButton x:Name="tooltipModButton"
HorizontalAlignment="Left"
Content="Tooltip"
ContentTemplate="{StaticResource TooltipIconContentTemplate}"
IsChecked="{Binding Source={x:Reference Name=tooltipTernaryModifier}, Path=IsEnabled, Mode=TwoWay}"
Style="{StaticResource DefaultToggleButtonStyle}"
ToolTipService.ToolTip="tooltip Ternary Modifier" />
<ext:FlyoutMenuButton HorizontalAlignment="Left"
Content="Leg"
Style="{StaticResource FlyoutMenuButtonStyle}"
ToolTipService.ToolTip="Legend">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<TextBlock Text="Legend source" />
<ComboBox ItemsSource="{Binding Source={ext:EnumValues {x:Type s:SourceMode}}}"
SelectedItem="{Binding Path=GetLegendDataFor,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay,
Converter={StaticResource SelectedEnumValueConverter}}" />
<ext:FlyoutSeparator />
<TextBlock Text="Legend placement" />
<ComboBox ItemsSource="{Binding Source={ext:EnumValues {x:Type s:LegendPlacement}}}"
SelectedItem="{Binding Path=LegendPlacement,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay,
Converter={StaticResource SelectedEnumValueConverter}}" />
<ext:FlyoutSeparator />
<TextBlock Text="Legend orientation" />
<ComboBox ItemsSource="{Binding Source={ext:EnumValues {x:Type Orientation}}}"
SelectedItem="{Binding Path=Orientation,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay,
Converter={StaticResource SelectedEnumValueConverter}}" />
<ext:FlyoutSeparator />
<CheckBox Margin="3"
VerticalAlignment="Center"
Content="Show legend"
IsChecked="{Binding Path=ShowLegend,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay}" />
<CheckBox Margin="3"
VerticalAlignment="Center"
Content="Show checkboxes"
IsChecked="{Binding Path=ShowVisibilityCheckboxes,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay}" />
<CheckBox Margin="3"
VerticalAlignment="Center"
Content="Show series markers"
IsChecked="{Binding Path=ShowSeriesMarkers,
Source={x:Reference ternaryLegendModifier},
Mode=TwoWay}" />
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
<ext:FlyoutMenuButton HorizontalAlignment="Left"
HorizontalContentAlignment="Center"
Content="THM"
FontSize="10"
Padding="0"
Style="{StaticResource FlyoutMenuButtonStyle}"
ToolTipService.ToolTip="Theme changing">
<ext:FlyoutMenuButton.PopupContent>
<StackPanel MinWidth="150" Orientation="Vertical">
<TextBlock FontSize="12" Text="Update Theme" />
<ext:FlyoutSeparator />
<ComboBox FontSize="12"
ItemsSource="{Binding Source={x:Static s:ThemeManager.AllThemes}}"
SelectedItem="{Binding Source={x:Reference sciTernaryChart},
Path=(s:ThemeManager.Theme),
Mode=TwoWay}" />
</StackPanel>
</ext:FlyoutMenuButton.PopupContent>
</ext:FlyoutMenuButton>
</WrapPanel>
</Border>
<s:SciChartTernarySurface x:Name="sciTernaryChart"
Grid.Column="1"
s:ThemeManager.Theme="SciChartv4Dark">
<s:SciChartTernarySurface.RenderableSeries>
<s:TernaryScatterRenderableSeries x:Name="scatterSeries1" s:TernaryTooltipModifier.TooltipTemplate="{StaticResource TooltipTernaryModifierLabelTemplate}">
<s:TernaryScatterRenderableSeries.PointMarker>
<s:EllipsePointMarker Width="7"
Height="7"
Fill="Aqua"
Stroke="Black"
StrokeThickness="1" />
</s:TernaryScatterRenderableSeries.PointMarker>
</s:TernaryScatterRenderableSeries>
<s:TernaryScatterRenderableSeries x:Name="scatterSeries2" s:TernaryTooltipModifier.TooltipTemplate="{StaticResource TooltipTernaryModifierLabelTemplate}">
<s:TernaryScatterRenderableSeries.PointMarker>
<s:TrianglePointMarker Width="11"
Height="11"
Fill="Blue"
Stroke="Black"
StrokeThickness="1" />
</s:TernaryScatterRenderableSeries.PointMarker>
</s:TernaryScatterRenderableSeries>
<s:TernaryScatterRenderableSeries x:Name="scatterSeries3" s:TernaryTooltipModifier.TooltipTemplate="{StaticResource TooltipTernaryModifierLabelTemplate}">
<s:TernaryScatterRenderableSeries.PointMarker>
<s:SquarePointMarker Width="7"
Height="7"
Fill="OrangeRed"
Stroke="Black"
StrokeThickness="1" />
</s:TernaryScatterRenderableSeries.PointMarker>
</s:TernaryScatterRenderableSeries>
</s:SciChartTernarySurface.RenderableSeries>
<s:SciChartTernarySurface.XAxisStyle>
<Style TargetType="s:TernaryNumericAxis">
<Setter Property="BorderBrush" Value="Blue" />
<Setter Property="BorderThickness" Value="0,0,1,0" />
<Setter Property="VertexLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisVertexLabel">
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Margin="0,3,0,3"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="20"
Foreground="Blue"
Text="Earth" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="TickLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisLabelTick">
<Setter Property="Foreground" Value="Blue" />
<Setter Property="TickLineStyle">
<Setter.Value>
<Style TargetType="Line">
<Setter Property="Stroke" Value="Blue" />
</Style>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</s:SciChartTernarySurface.XAxisStyle>
<s:SciChartTernarySurface.YAxisStyle>
<Style TargetType="s:TernaryNumericAxis">
<Setter Property="BorderBrush" Value="OrangeRed" />
<Setter Property="BorderThickness" Value="1,0,0,0" />
<Setter Property="VertexLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisVertexLabel">
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Margin="0,3,0,3"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="20"
Foreground="OrangeRed"
Text="Fire" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="VertexTitle" Value="Fire" />
<Setter Property="TickLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisLabelTick">
<Setter Property="Foreground" Value="OrangeRed" />
<Setter Property="TickLineStyle">
<Setter.Value>
<Style TargetType="Line">
<Setter Property="Stroke" Value="OrangeRed" />
</Style>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</s:SciChartTernarySurface.YAxisStyle>
<s:SciChartTernarySurface.ZAxisStyle>
<Style TargetType="s:TernaryNumericAxis">
<Setter Property="BorderBrush" Value="Aqua" />
<Setter Property="BorderThickness" Value="0,0,1,0" />
<Setter Property="VertexLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisVertexLabel">
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Margin="0,3,0,3"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="20"
Foreground="Aqua"
Text="Air" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="VertexTitle" Value="Air" />
<Setter Property="TickLabelStyle">
<Setter.Value>
<Style TargetType="s:TernaryAxisLabelTick">
<Setter Property="Foreground" Value="Aqua" />
<Setter Property="TickLineStyle">
<Setter.Value>
<Style TargetType="Line">
<Setter Property="Stroke" Value="Aqua" />
</Style>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</s:SciChartTernarySurface.ZAxisStyle>
<s:SciChartTernarySurface.ChartModifier>
<s:TernaryModifierGroup>
<s:TernaryCursorModifier x:Name="cursorTernaryModifier" />
<s:TernaryTooltipModifier x:Name="tooltipTernaryModifier" />
<s:TernaryLegendModifier x:Name="ternaryLegendModifier"
Margin="10"
Orientation="Vertical"
ShowLegend="False" />
</s:TernaryModifierGroup>
</s:SciChartTernarySurface.ChartModifier>
</s:SciChartTernarySurface>
</Grid>
</UserControl>
using System;
using System.Windows.Controls;
using SciChart.Charting.Model.DataSeries;
using SciChart.Examples.ExternalDependencies.Data;
namespace SciChart.Examples.Examples.CreateTernaryChart
{
/// <summary>
/// Interaction logic for ScatterSeriesTernaryChartExampleView.xaml
/// </summary>
public partial class ScatterSeriesTernaryChartExampleView : 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 RandomWalkGenerator _random;
public ScatterSeriesTernaryChartExampleView()
{
InitializeComponent();
_random = new RandomWalkGenerator(seed: 0);
// scatters series
var scatterDataSeries1 = new XyzDataSeries<double> { AcceptsUnsortedData = true, SeriesName = "Substance A" };
var scatterDataSeries2 = new XyzDataSeries<double> { AcceptsUnsortedData = true, SeriesName = "Substance B" };
var scatterDataSeries3 = new XyzDataSeries<double> { AcceptsUnsortedData = true, SeriesName = "Substance C" };
// Air series
for (int i = 0; i < 75; i++)
{
var x = _random.Next(0, 50);
var z = _random.Next(20, 40);
var y = 100 - (x + z);
scatterDataSeries1.Append(x, y, z);
}
// Earth series
for (int i = 0; i < 75; i++)
{
var x = _random.Next(0, 40);
var z = _random.Next(0, 20);
var y = 100 - (x + z);
scatterDataSeries2.Append(x, y, z);
}
// Fire series
for (int i = 0; i < 75; i++)
{
var x = _random.Next(20, 40);
var y = _random.Next(0, 25);
var z = 100 - (x + y);
scatterDataSeries3.Append(x, y, z);
}
scatterSeries1.DataSeries = scatterDataSeries1;
scatterSeries2.DataSeries = scatterDataSeries2;
scatterSeries3.DataSeries = scatterDataSeries3;
}
}
}