How to stop showing decimal points in Y Axis in WP

2019-07-05 03:12发布

问题:

I am using WPF DataVisualization chart control to show some sample data. My problem is Y axis is showing decimal values. How can I make it show only integer values.

This is my XAML code for the

<chartingToolkit:Chart Margin="0,30,0,30" Name="columnChart" Title="" Foreground="Black"  >
    <chartingToolkit:ColumnSeries DependentValuePath="Value" Background="Red"  
    IndependentValuePath="Key" ItemsSource="{Binding}"  >
        <chartingToolkit:ColumnSeries.DataPointStyle>
            <Style TargetType="Control">
                <Setter Property="Background" Value="#A80729"/>
            </Style>
        </chartingToolkit:ColumnSeries.DataPointStyle>
    </chartingToolkit:ColumnSeries>
</chartingToolkit:Chart>

snapshot of the chat here

回答1:

set interval and Minimum,

some thing like,

    <chartingToolkit:ColumnSeries.DependentRangeAxis>
                <chartingToolkit:LinearAxis FontSize="15" Foreground="White" Interval="1" Minimum="0" Orientation="Y" ShowGridLines="False" />
            </chartingToolkit:ColumnSeries.DependentRangeAxis>
            <chartingToolkit:ColumnSeries.IndependentAxis>
                <chartingToolkit:CategoryAxis FontSize="12" Foreground="Gray" Orientation="X" ShowGridLines="False" />
            </chartingToolkit:ColumnSeries.IndependentAxis>

hope this helps!