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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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
    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.