无十进制数字的LinearAxis [英] LinearAxis without decimal numbers

查看:112
本文介绍了无十进制数字的LinearAxis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想避免使用Axis中的十进制数字,怎么办呢?

I want to avoid from decimal numbers in my Axis, how can I do that ?

XAML:

 <Charting:Chart   VerticalAlignment="Stretch" 
                HorizontalContentAlignment="Stretch">

        <Charting:Chart.Axes>
            <Charting:LinearAxis  Orientation="Y" Minimum="0" Title="" Location="Left"
                    />
        </Charting:Chart.Axes>

        <Charting:Chart.Series>

            <Charting:ColumnSeries ItemsSource="{Binding Persons}"
                        DependentValueBinding="{Binding Count}"
                        IndependentValueBinding="{Binding Category}">
            </Charting:ColumnSeries>
        </Charting:Chart.Series>
    </Charting:Chart>


推荐答案

如果您仍在为此苦苦挣扎,或者如果有人感兴趣:
解决方案几乎就是baalazamon编写的。只是{0:0。##}将显示两个十进制数字(如果存在的话)(这就是。##的意思)。因此,您应该写的是

In case you're still struggling on this, or if anyone else is interested: the solution is almost what baalazamon wrote. It's just that {0:0.##} will display two decimal digits if they exists (that's what ".##" means). So what you should write is

<Style x:Key="EmptyStyle" TargetType="charting:NumericAxisLabel"> 
    <Setter Property="IsTabStop" Value="False" /> 
    <Setter Property="StringFormat" Value="{0:0}" /> 
    <Setter Property="Template"> 
        <Setter.Value> 
            <ControlTemplate TargetType="charting:NumericAxisLabel"> 
                <TextBlock /> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style>

当然,您需要添加以下内容:

And of course you need to add this:

<charting:LineSeries.DependentRangeAxis>    
        <charting:LinearAxis AxisLabelStyle="{StaticResource EmptyStyle}"    
            Orientation="Y"    
            ShowGridLines="True"/>    
</charting:LineSeries.DependentRangeAxis>

我希望这可以解决您的问题。

I hope this will solve your problem.

这篇关于无十进制数字的LinearAxis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆