ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Getting YValue for Any XValue for Any Type of LineLayer And their Coordinates
Posted by KarenA on May-30-2016 01:47
Please let me know if there is a way to do what i need. If Not please consider this as a feature request. It is functionality I just assumed would be in ChartDirector and I was surprised I could not see a way to do it wining ChartDirector itself.

This is most needed for data analysis for  SplineLayer when plotting a continuous signal nosey signal (usually after some smoothing) and you need to get values between data points or find maxima or minima etc.

From a trendLayer I can calculate the Y value for any X Value using the fit formulas and that is great... but those are not the only lines CD draws.

I would be happy with this just for a SplineLayer, but it would be nice to have a consistent API across all (2D at least) LineLayer types.

Maybe something like this that would work for point to point and Spline  lines (and you might as well make it for for trendLine layers too):

Func LineLayer.GetLineYValue(xValue as Double, DatasetIdx as integer = 0) As Double
And/Or
Func LineLayer.GetLineYCoord(xCorr as Integer, DatasetIdx as integer = 0) As Integer

The corresponding GetLineX from Y would be nice but lower priority

That would allow data analysis from a spline curve and be able to write a tarcking routine for the curve Vs the data points for Splinelayers AND allow it do be dome for all lines with the same code.

Please tell me what you think.

Karen

  Re: Getting YValue for Any XValue for Any Type of LineLayer And their Coordinates
Posted by Peter Kwan on May-31-2016 00:40
Hi KarenA,

Unluckily, there is no API in ChartDirector to determine the points along a spline curve.

- ChartDirector does not necessarily draw or know every point along the spline curve. For example, in SVG or PDF output, for each curve segment, it only outputs several points and instruct the SVG viewer or PDF viewer to join the points with a spline (eg. a Beizer curve).

- In case ChartDirector renders the chart into pixels, it may not keep track of every pixel it has drawn, as there are too many pixels. Usually, it just draws one pixel, then forgets about it, then draws the next pixel and so on.

- As is common for spline curves, the curve is defined parametrically. Without going into details, the result is that ChartDirector internally does not have an algorithm to compute x from y or y from x. Instead, it only obtains a few (x, y) points on the spline (typically less than 5%) and joins them with straight lines to approximate the curve visually.

- Unlike linear regression, there is no standard to draw a spline curve, so a spline curve is just an arbitrary curve that passes through the data points and looks nice. Different implementations can draw the curve differently. The points along on a spline curve has no meaning other than looking nice.

In cases that need to analyze the data seriously, usually the data would need to be interpolated using an algorithm appropriate for the data. For example, if the data are temperatures, the data may need to be interpolated using some theory of thermodynamics. If they are electric fields, theory of electromagnetism may be used.

For your case, you may need to use your own method to interpolate the data to obtain the additional points you need. Then you can include those points with your original data and pass to ChartDirector for plotting.

Regards
Peter Kwan

  Re: Getting YValue for Any XValue for Any Type of LineLayer And their Coordinates
Posted by KarenA on May-31-2016 04:37
Thanks for the reply.

In my case I don't know of any mathematical model to calculate the in-between data but since natural phenomena tend to vary continually,  I thought it likely that the spline curve  approximated the the underlying phenomenon would better than a straight line between points...

I'm not a mathematician or physicist so obviously I could be wrong

- Karen