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.

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.