Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinearAxis without decimal numbers

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

enter image description here

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>
like image 391
Erez Avatar asked Feb 26 '23 07:02

Erez


1 Answers

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.

like image 58
benj35000 Avatar answered Mar 08 '23 16:03

benj35000