Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Xaml datagrid XAxis legend with negative minimum value displaying oddly

I'm attempting to display a data chart which uses a negative minimum value and a range which crosses zero to it maximum value. 

X Min = -2000,  X Max = 1800, Range = -2000 to 18000

Y Min = 0, Y Max = 250 Y Range = 0 to 250

When displaying the chart fails to align the X and Y vertices at 0,0.  Is this possible? 

Note that for this data there are no X data values less than 0 but if there were I would expect them to appear before the Y axis.  

Here's my XAML:

Note that the dataplot and legends are rendered dynamically

<!-- *** Histogram Graph Section *** -->
<DataTemplate x:Name="templateName">
<Grid x:Name="graphGrid">
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="*"/>
<ig:XamDataChart x:Name="DataChart" Margin="0,10,10,0"
Grid.Row="0" Grid.Column="1"
Height="{Binding TileGraphHeight, Source={StaticResource HistogramViewModel}}"
Width="{Binding TileGraphWidth, Source={StaticResource HistogramViewModel}}"
VerticalAlignment="Stretch" >
<local1:LabelTranslateConverter x:Key="LabelTranslateConverter"/>
<Style TargetType="ig:CategoryXAxis">
<Setter Property="Label">
<TextBlock Name="txt1"
Text="{Binding Item.Category}"
<Binding Converter="{StaticResource LabelTranslateConverter}"
RelativeSource="{RelativeSource AncestorType=ig:XamDataChart}"
<ig:NumericYAxis x:Name="YAxis" MinimumValue="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Item}" />
<TextBlock Text="{Binding YLabelSuffix, Source={StaticResource HistogramViewModel}}" />
<ig:CategoryXAxis x:Name="XAxis" ItemsSource="{Binding Series}" Interval="1" >
<ig:AxisLabelSettings Angle="90" />
<ig:ColumnSeries ItemsSource="{Binding Series}" ValueMemberPath="Value"
Title="Parameter Spectrum Data"
XAxis="{Binding ElementName=XAxis}"
YAxis="{Binding ElementName=YAxis}">
<TextBlock Text="{Binding Item.Value, StringFormat=\{0:n1\}}" />
<ig:ItemToolTipLayer TargetSeries="{Binding ElementName=series1}" />

<TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,20,0"
Text="{Binding NetTimeLabel}"
<TextBlock x:Name="XAxisLabel" Grid.Row="1" Grid.Column="1" Text="{Binding DomainLabel}"
HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" />
<TextBlock x:Name="RotatedLabel" Grid.Row="0" Grid.Column="0" Text="{Binding RangeLabel}"
Width="150" Height="20"
<CompositeTransform Rotation="-90"/>
<Border BorderThickness="2" BorderBrush="Gray" Visibility="{Binding IsExportTabSelected, Source={StaticResource HistogramViewModel}, Converter={StaticResource VisibilityConverter}}">
<CheckBox IsChecked="{Binding ToBeExported, Mode=TwoWay}" HorizontalAlignment="Right"/>



  • 29150
    Suggested Answer
    Offline posted

    Hello Wil,

    It is possible to align the X and Y vertices at (0,0). In order to do this, I would recommend that you set the CrossingAxis property on your NumericYAxis to your XAxis. You will also need to set the CrossingValue property. In the case of the CategoryXAxis shown in your screenshot, this CrossingValue property will be the index of the category that holds the value “0” in your underlying ItemsSource.

    Doing this will align the Y-axis line with zero on the XAxis. If you will have a NumericYAxis that will go less than zero, you will need to do the same thing with the CategoryXAxis in this case, but with the CrossingValue being the value on the numeric axis that you want it to cross over.

    It is worth noting that unless you set the NumericYAxis.LabelSettings.Location property, the labels will still remain on the “outside” of the chart. If you set them to “InsideLeft” or “InsideRight” they will align with the grid-line. It is worth noting though, that there is no functionality currently to have the series avoid collision with the axis lines or labels. If you set the Location property mentioned above to exist in the plot area, the labels will be drawn over the top of the series that are plotted in the chart.

    I am attaching a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data