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
- Christopher asked 11 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 11 years ago
- You must login to post comments
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
- Christopher answered 11 years ago
- You must login to post comments
Please login first to submit.