When defining a graph element one of the optional properties that can
be defined is a DataMarkerTemplate. By default, the template is defined as a
square of 5 pixels; achieved through the XAML specification:
<DataTemplate x:Key="ELEMENT_dataMarkerTemplate">
<Rectangle Canvas.ZIndex="10" Height="5" Width="5"
Fill="Blue" Stroke="Black" StrokeThickness="3"
local:GraphBase.XOffset="-2.5" local:GraphBase.YOffset="-2.5" />
</DataTemplate>
However, it is possible to define templates specific to a graph
instance. This is achieved by specifying the required DataTemplate within the
application XAML. An example of DataTemplate specification for a Square, Circle,
Triangle and Diamond would be:
<DataTemplate x:Key="Square">
<Rectangle Canvas.ZIndex="10" Width="5" Height="5" Fill="#990000"
Stroke="Black" StrokeThickness="1"
local:GraphBase.XOffset="-2.5" local:GraphBase.YOffset="-2.5" />
</DataTemplate>
<DataTemplate x:Key="Circle">
<Ellipse Canvas.ZIndex="10" Width="5" Height="5" Fill="#CC6600"
Stroke="Black" StrokeThickness="1"
local:GraphBase.XOffset="-2.5" local:GraphBase.YOffset="-2.5" />
</DataTemplate>
<DataTemplate x:Key="Triangle">
<Polygon Canvas.ZIndex="10" Width="6" Height="6" Fill="#B966B9"
Stroke="Black" StrokeThickness="1"
local:GraphBase.XOffset="-3" local:GraphBase.YOffset="-3"
Points="0,6 6,6 3,0" />
</DataTemplate>
<DataTemplate x:Key="Diamond">
<Rectangle Canvas.ZIndex="10" Width="5" Height="5" Fill="#2932E0"
Stroke="Black" StrokeThickness="1"
local:GraphBase.XOffset="-2.5" local:GraphBase.YOffset="-2.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="45" CenterX="2.5" CenterY="2.5" />
</Rectangle.RenderTransform>
</Rectangle>
</DataTemplate>
The specifications of the X and Y offset are necessary to ensure the
center of the data marker represents the actual point on the graph.
For TimeIBarGraph implementation of the data marker template is a
little different. In this case the height of the template needs be determined by
the data bounds values. The XAML for the two common representations for range
values, namely an IBar and an Arrow, is defined as:
<DataTemplate x:Key="IArrowMarker">
<Grid Canvas.ZIndex="10" Height="10" Width="8"
ctl:GraphBase.XOffset="-4" ctl:GraphBase.YOffset="0"
ctl:GraphBase.SnapToPixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="4"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Height="4">
<Polyline Points="0,4, 4,0, 8,4" Stroke="Black" StrokeThickness="1"
StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Polyline Points="4,4, 4,0" Stroke="Black" StrokeThickness="2"
StrokeStartLineCap="Square" StrokeEndLineCap="Round"/>
</Grid>
<Rectangle Grid.Row="1" HorizontalAlignment="Center" Fill="Black" Width="2"/>
<Grid Grid.Row="2" Height="4">
<Polyline Points="0,0, 4,4, 8,0" Stroke="Black" StrokeThickness="1"
StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Polyline Points="4,0, 4,4" Stroke="Black" StrokeThickness="2"
StrokeStartLineCap="Square" StrokeEndLineCap="Round"/>
</Grid>
</Grid>
</DataTemplate>
<DataTemplate x:Key="IBarMarker">
<Grid Canvas.ZIndex="10" Height="9" Width="9" ctl:GraphBase.XOffset="-4.5"
ctl:GraphBase.YOffset="-1.5" ctl:GraphBase.SnapToPixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="3"/>
<RowDefinition Height="*"/>
<RowDefinition Height="3"/>
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" VerticalAlignment="Top"
Height="3" Width="9" Fill="Black"/>
<Rectangle Grid.Row="1" HorizontalAlignment="Center"
Fill="Black" Width="1"/>
<Rectangle Grid.Row="2" VerticalAlignment="Bottom"
Height="3" Width="9" Fill="Black"/>
</Grid>
</DataTemplate>
Once the DataTemplate specifications have been made, the corresponding
DataMarkerTemplate property can be defined for each Graph; such as:
DataMarkerTemplate="{StaticResource Square}"
DataMarkerTemplate="{StaticResource Diamond}"
DataMarkerTemplate="{StaticResource IBarMarker}"