Pre loader

YAxis label alignment

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
0
0

I want to align my left YAaxis labels to right and fixed label width. I use Spectrogram view and want to align the left edges of those charts. (I’m using version 4.0.2)

This is my style definition:

 <Style x:Key="LeftAxisLabelStyle" TargetType="s:DefaultTickLabel">
    <Setter Property="HorizontalAnchorPoint" Value="Right"/>
    <Setter Property="Width" Value="20"/>
 </Style>

but unfortunately it doesn’t work.

  • You must to post comments
Best Answer
0
0

Hi Andrew,

Unfortunately your solution does not solve my problem. But I have found my own one. Here you are:

<Style x:Key="LeftAxisLabelStyle" TargetType="s:DefaultTickLabel">
    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Width="40" TextAlignment="Right" Text="{Binding Text}"/>
                </StackPanel>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

Best regards,
Marek

  • Andrew Burnett-Thompson
    Hi Marek, thank you for sharing that answer, it will surely help other people too! Best regards, Andrew
  • You must to post comments
0
0

Hi Marek,

Thank you for your question! The default axis layout doesn’t allow to right-align its internals. But, it is possible to right-align the entire axis instead.

You can achieve the desired result providing a panel with a desired Width as LeftAxesPanelTemplate and setting HorizontalAlignment on the axis:

     <ItemsPanelTemplate x:Key="LeftAxesPanel">
         <!-- Set the desired width on the panel -->
         <Grid Width="100"/>
     </ItemsPanelTemplate>

     <!-- Use the panel as a container for left-aligned axes -->
     <s:SciChartSurface LeftAxesPanelTemplate="{StaticResource LeftAxesPanel}">

        <s:SciChartSurface.YAxis>
            <s:NumericAxis Id="LeftAxis" AxisAlignment="Left"  />
        </s:SciChartSurface.YAxis>

    </s:SciChartSurface>

Please let me know if this helps.

Best regards,
Andrew

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies