Pre loader

Changing CursorModifier Axis Label string format

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

0
0

Hello guys

How to change Crosshair annotation string format?
I need to round it to decimals. shall i make new Control Template?

Images
  • You must to post comments
0
0

The CursorModifier gets its data from the Axis, see the method AxisBase.HitTest, which has this signature:

/// <summary>
/// Performs a hit test on the Axis, returning the Data Value at the specific x or y pixel coordinate. This operation is the opposite of <see cref="AxisBase.GetCoordinate"/>
/// </summary>
/// <param name="atPoint">The pixel coordinate on this Axis corresponding to the input DataValue</param>
/// <returns>An <see cref="AxisInfo"/> struct containing the datavalue and formatted data value at this coordinate</returns>
/// <remarks></remarks>
public override AxisInfo HitTest(Point atPoint);

The HitTest method on NumericAxis uses the AxisBase.TextFormatting and AxisBase.CursorTextFormatting properties to format strings (for axis and for cursor labels).

Please try changing YAxis.CursorTextFormatting and let me know if that updates your cursor label output.

Alternatively, if you do need to template the cursor axis labels, you can do so by setting the CursorModifier.CursorAxesLabelTemplate property with a custom template. Don’t worry, this one’s pretty short and sweet:

    <!--  Template for the CursorModifier axes tooltips to display AxisInfo collection (result of hit test)  -->
    <ControlTemplate x:Key="CursorAxesLabelTemplate" TargetType="SciChart:TemplatableControl">
        <Border Margin="1"
                Background="#333"
                BorderBrush="#FFF"
                BorderThickness="1"
                CornerRadius="2">
            <TextBlock Foreground="#FFF" Text="{Binding CursorFormattedDataValue}" />
        </Border>
    </ControlTemplate>

Hope this helps!

Yuriy

  • VRueda
    Hello, Yuriy Thanks, now it works Only IAxis.TextFormatting needed
  • You must to post comments
0
0

Update: SciChart v4

The SciChart v4 Documentation now has a topic on styling the CursorModifier Tooltips, Lines and Axis Labels. You can see this here:

> How to style the CursorModifier Tooltips

Also, you can learn how to styling and configuring the CursorModifier Tooltips and Axis Labels in the following example:

> Styling CursorModifier Tooltips WPF Chart Example

enter image description here

  • 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