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

0
0

I have built a file availability chart displaying point markers for dates. The marker is being displayed on the left-most edge for each category. The effect is that when the user hovers directly over a marker it will often shown the wrong date in the mouse over label. Is there a way to center the point marker alignment with the category axis?

I’m using WPF version 3.4

Images
  • You must to post comments
0
0

I think this is a rounding issue. The marker itself is centered on the X,Y point that you display, but the cursor won’t snap to the middle of the point so as you move the cursor over the point itself, there is some ‘give’ in the values it displays.

You may be able to force rounding to the nearest day by using a Converter inside an Axis Label Template, e.g. from our Documentation:

CursorModifier Axis Labels come with a default style. This style can be overridden by setting the CursorModifier.AxisLabelContainerStyle and/or CursorModifier.AxisLabelTemplate attached properties on the relevant axis.
For example:

<!-- Demonstrates custom cursor axis label style --> 
<s:SciChartSurface>
   <s:SciChartSurface.Resources>      
      <!-- This is the style for the control that hosts the Axis Label --> 
      <Style x:Key="CursorModAxisLabelStyle" TargetType="s:AxisLabelControl">
         <Setter Property="Background" Value="#AAFF6600" />
         <Setter Property="BorderBrush" Value="#FFFF6600" />
         <Setter Property="BorderThickness" Value="1" />
      </Style>

      <!-- This is the DataTemplate for the Axis Label. DataContext is AxisInfo -->
      <DataTemplate x:Key="CursorModAxisLabelTemplate" DataType="s:AxisInfo">
         <StackPanel>
            <TextBlock Foreground="White" FontFamily="Arial" FontSize="11" Margin="2"
                       Text="{Binding DataValue, StringFormat='{}{0:0.00}'}" />
         </StackPanel>
      </DataTemplate>
   </s:SciChartSurface.Resources>

   <!--  Declare Axes with CursorLabelTemplates -->
   <s:SciChartSurface.XAxis>
      <s:NumericAxis s:CursorModifier.AxisLabelContainerStyle="{StaticResource CursorModAxisLabelStyle}" 
                     s:CursorModifier.AxisLabelTemplate="{StaticResource CursorModAxisLabelTemplate}" />
   </s:SciChartSurface.XAxis>

   <s:SciChartSurface.YAxis>
      <s:NumericAxis s:CursorModifier.AxisLabelContainerStyle="{StaticResource CursorModAxisLabelStyle}" 
                     s:CursorModifier.AxisLabelTemplate="{StaticResource CursorModAxisLabelTemplate}" />
   </s:SciChartSurface.YAxis>

   <s:SciChartSurface.ChartModifier>
      <s:ModifierGroup>         
         <s:CursorModifier ShowAxisLabels="true"/>
      </s:ModifierGroup>
   </s:SciChartSurface.ChartModifier>

</s:SciChartSurface>

There’s a StringFormat in the CursorModAxisLabelTemplate but you could easily replace this for a Converter which rounds to the nearest date.

Let me know if this helps,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.