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
20
NumericXAxis Axis Label formatting
posted

Hello,

My NumericXAxis is binded to values from 0 to 280. In the label, I want to show Label as -> value/28. (i.e. the value it obtains from binding and then divided by 28)

How can I do such formatting. 

I tried these:

<ig:NumericXAxis x:Name="xmXAxis" Label="{}{0%28}"
MinimumValue="0"
MaximumValue="280"
MajorStroke="DarkGray"
MajorStrokeThickness="0.3"
MinorStroke="DarkGray"
MinorStrokeThickness="0"
Interval="28">

or Label="{}/28"

But its not working.

Any help?

Thanks!

Parents
  • 30692
    Suggested Answer
    Offline posted

    Here's one way of going about it:

    <ig:XamDataChart x:Name="theChart">
                <ig:XamDataChart.Axes>
                    <ig:NumericXAxis x:Name="xmXAxis" 
                        MinimumValue="0" 
                        MaximumValue="280" 
                        MajorStroke="DarkGray"
                         MajorStrokeThickness="0.3"
                         MinorStroke="DarkGray"
                         MinorStrokeThickness="0"
                         Interval="28" >
                        <ig:NumericXAxis.Label>
                            <DataTemplate>
                                <TextBlock Text="{Binding Item, Converter={StaticResource divBy28}}" />
                            </DataTemplate>
                        </ig:NumericXAxis.Label>
                    </ig:NumericXAxis>
                </ig:XamDataChart.Axes>
            </ig:XamDataChart>
    

    With code behind:

        public class DivBy28
            : IValueConverter
        {
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return (double)value / 28.0;
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    
    


    Hope this helps!

    -Graham

Reply Children
No Data