Pre loader

Ratio between X and Y Axis

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,

is it possible to show/calculate the ratio between X and Y Axis?

i need to show the exaggeration between the x and y axis.

eg
yAxis 5m / 100px
XAxis 500m / 100px
-> exaggeration factor = 100

Thanks

Thanks
Christopher

  • You must to post comments
0
0

Ah I see, thanks again for clarification

Alright we have an API to convert data & pixel coordinates. Can you try something like this?


    // Inside OnRender event handler
    // .. 

    // What is current MajorDelta on the chart xaxis? 
    double majorDelta = sciChartSurface.XAxis.MajorDelta;

    // Use CoordinateCalculator API to convert pixels to coordinates and back
    var coordCalc = sciChartSurface.XAxis.GetCurrentCoordinateCalculator();

    // How many pixels = 1 major delta? 
    double pixelsPerDivision = coordCalc.GetCoordinate(sciChartSurface.XAxis.VisibleRange.Min + majorDelta);

    // Output values
    Console.WriteLine("xAxis {0}m / {1}px", majorDelta, pixelsPerDivision);

    // TODO: Output to TextBlock on the UI
}

There are other variations you could do. Once you get XAxis.GetCurrentCoordinateCalculator() you can transform data values to pixels (using GetCoordinate) or pixels to data values (using GetDataValue). Use this API to calculate the exaggeration and output to a TextBlock on the screen.

Please note coordinate calculator is only valid for the current render pass, get it fresh every time

Does this help?

  • Andrew
  • You must to post comments
0
0

Hi,
this helped a lot.

Here is the final Implementation

Public Class SciChartSurfaceExt
Inherits SciChartSurface

    Public Shared ReadOnly ExaggerationProperty As DependencyProperty = DependencyProperty.Register("Exaggeration", GetType(Double), GetType(SciChartSurfaceExt), New FrameworkPropertyMetadata(Nothing))

    Public Property Exaggeration As Double
        Get
            Return CDbl(GetValue(ExaggerationProperty))
        End Get

        Set(ByVal value As Double)
            SetValue(ExaggerationProperty, value)
        End Set
    End Property

    Private Sub SciChartSurfaceExtRendered(sender As Object, e As EventArgs) Handles Me.Rendered
        If XAxis.IsNull() OrElse YAxis.IsNull() Then Return
        Try
            Dim majorDeltaX = ConvertToDouble(XAxis.MajorDelta)
            Dim minX = ConvertToDouble(XAxis.VisibleRange.Min)
            Dim coordCalcX = XAxis.GetCurrentCoordinateCalculator()

            Dim pixelsPerDivisionX = (coordCalcX.GetCoordinate(minX + majorDeltaX) - coordCalcX.GetCoordinate(minX)) / majorDeltaX

            Dim majorDeltaY = ConvertToDouble(YAxis.MajorDelta)
            Dim maxY = ConvertToDouble(YAxis.VisibleRange.Max)
            Dim coordCalcY = YAxis.GetCurrentCoordinateCalculator()

            Dim pixelsPerDivisionY = (coordCalcY.GetCoordinate(maxY - majorDeltaY) - coordCalcY.GetCoordinate(maxY)) / majorDeltaY

            Exaggeration = pixelsPerDivisionY / pixelsPerDivisionX

        Catch
            Exaggeration = 0
        End Try

    End Sub

Christopher

  • 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