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



I was trying to get the max value on the y axis for the visible window, so that I can manually scale the y axis visible range (so I can control the increments and the y axis maximum). To get the max y data in the window, I’ve written in Kotlin:

var coordinateCalc = xUoAxes[0].createCoordinateCalculatorFrom(xUoAxes[0].visibleRange) //get visible range of coordinates
var coordMin = coordinateCalc.minAsDouble //debug var
var coordMax = coordinateCalc.maxAsDouble //debug var
var dataRange = yUoAxes.getAxisById("uoId").dataRange //debug var
var test = mapOf("test" to coordinateCalc)  //create map for getWindowedYRange, providing the coordinateCalculator
var windowedYRangeUo = yUoAxes.getAxisById("uoId").getWindowedYRange(test)  //I think this should pass back the same value as dataRange?

However, the getWindowedYRange result is significantly different from dataRange, and while debugging, there is only a single data point in yUoAxes.

I wasn’t sure if I’m using the right function, or if I’m using it incorrectly (or if this is even the correct approach to this problem)?


  • You must to post comments
Best Answer

Hi Andrew,

The are some differences between getDataRange() and getWindowedYRange() methods:
– first one calculates range for entire data set ( even for points which are outside VisibleRange of xAxis ) and second one uses only data which are currently on screen ( uses VisibleRange of xAxis to determine range of point to use for calculation ).
– second one applies GrowBy value specified for YAxis, and getDataRange() just calculates Min/Max bounds of data set without any modification

Best regards,

  • Andrew Chin
    Hi Yura, That was my impressions of the functionality, but there is currently only a single point on the graph as of that snapshot (xUoAxes =1), and by no means should the dataRange be less than the getWindowedYRange(), as the getWindowedYRange is a subset of dataRange. However, from the debug in the screenshot, you can see the range for dataRange is 0 to 109 (which is what is expected), but the getWindowedYRange() gets a range of 0 to 1199. I was wondering if I’m doing something wrong with the GrowBy functionality? the y axis was generated via: var yAxis = NumericAxis(context).apply { axisId = uoId autoRange = AutoRange.Never growBy = DoubleRange(0.0, 10.0) axisAlignment = AxisAlignment.Right drawMajorGridLines = true drawMinorGridLines = false visibleRangeLimitMode = RangeClipMode.Min visibleRange = DoubleRange(0.0, 100.0) setAxisTitleMargins(0,0, 20,0) } Thanks, -Andy
  • Andrew Chin
    Never mind – got it. My understanding of the grow_by functionality was incorrect, and was effectively multiplying the dataRange by 10 (and appending it to the already existing 109). I set the grow_by range to 0, and now the numbers look good. Thanks so much for your help! -Andy
  • Andrew Chin
    Hmm, so upon further investigation, it looks like getWindowedYRange is based on the visible range rather than the data range. Is there anything like the getDataRange() for just the window, rather than the entire dataset? Thanks, -Andy
  • Andrew Burnett-Thompson
    Hi Andrew, have you considered just xAxis.getVisibleRange() then iterating over your DataSeries to find the Min,Max Y-value in that x-range? that’s basically what we do internally. Just a suggestion on how to access your data in a simpler way
  • Andrew Chin
    Yeah, that was going to be my fall back. I figured I’d capture the visible range change event, and iterate through the visible range each time to find the Max and min Y. My primary concern is if I’ll be able to get it running sufficiently fast such that I didn’t have lag during rendering (although I’m not sure how many points we want to render on the screen yet at max, so this may be an unfounded concern). Thanks for the response!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.