SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

The tick labels of a MATLAB log-scale plot can display as “10^X “.
https://www.mathworks.com/help/matlab/ref/loglog.html

But the log-scale axis in the examples has a style like “Num X 10 ^X”. Is it a way to customize these labels to remove “Num X” before “10^X”?

Furthermore, how to set which value could display a label? I just want the label with integer superscripts. For example, if the VisibleRange = (0.01,1000), only the following tick values :0.01,0.1,1,10,100,1000 can display an label.

PS.
If cannot remove the prefixed “Num X” easily, is it possible to make the labels show the value not using scientific numbers? (display 0.01,0.1,1,10,100,1000 directly)

Version
6.1
  • You must to post comments
0
0

Hi there,

Thanks for your inquiry.

In SciChart, it is possible to customize Axis labels using WPF capabilities – Styling and Templating. You could provide a custom Style for Axis Labels and assign it to the TickLabelStyle property on your LogarithmicAxis. Please take a look at this documentation article to learn more.

Also, it is possible to configure DataContext for AxisLabels when more flexibility is needed. Please take a look at this article to find out more.

I created a Style to achieve the desired look of Labels on Logarithmic Axis, please find it below:

            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <s:ValueMultiplicatorConverter x:Key="ValueMultiplicatorConverter"/>
            <s:ValueToTopMarginConverter x:Key="ValueToTopMarginConverter"/>

            <Style x:Key="MatLabLogarithmicLabelStyle" TargetType="{x:Type s:NumericTickLabel}">
                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate DataType="{x:Type s:NumericTickLabelViewModel}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock
                                    Margin="{Binding ., RelativeSource={RelativeSource Self}, Converter={StaticResource ValueToTopMarginConverter}, ConverterParameter=0.5}"
                                    Text="{Binding Separator}"
                                    Visibility="{Binding HasExponent, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <TextBlock
                                    x:Name="exponent"
                                    FontSize="{Binding FontSize, RelativeSource={RelativeSource AncestorType=s:NumericTickLabel}, Converter={StaticResource ValueMultiplicatorConverter}, ConverterParameter=0.83}"
                                    Text="{Binding Exponent}"
                                    Visibility="{Binding HasExponent, Converter={StaticResource BooleanToVisibilityConverter}}" />
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

Please try setting that Style as TickLabelStyle and let me know if it works as expected.

Best Regards,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.