Recent

Author Topic: TAChart with spline series  (Read 24564 times)

WDB463

  • New Member
  • *
  • Posts: 11
Re: TAChart with spline series
« Reply #15 on: July 01, 2011, 11:46:06 am »
The "DrawIfIncorrect" may be a good idea to overcome the difference between mathematic correctness and users expectation.

From the application side an example: If you have a manual input of the points (e.g. measured values for x and y, not time dependent x) the expectation is, that the points will be shown directly after input of the values. Now it could be possible to draw only the points, to draw a line going through the points or draw nothing. In my opinion the second version seems the best for practice use comparable to the usual Excel chart with smoothing.

WDB463

  • New Member
  • *
  • Posts: 11
Re: TAChart with spline series
« Reply #16 on: July 01, 2011, 02:03:23 pm »
Actually the curve will be drawn also outside the first and last points. This can be seen especially when the TChart.Extend values are set. This may be sense full for extrapolations but is sometimes confusing. I would suggest two properties ExtrapolatingXMin and ExtrapolatingXMax.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart with spline series
« Reply #17 on: July 02, 2011, 05:53:50 pm »
All the changes below are available since r31509.

Quote
If the line exceeds the maximum or minimum of the points y values it will be cut.
Fixed.

Quote
The "DrawIfIncorrect" may be a good idea to overcome the difference between mathematic correctness and users expectation.
I have implemented very detailed control over this feature, since I feel it has potential for confusion.
1) There are two options: csoDrawFewPoints and csoDrawUnorderedX, disabled by default.
2) The "incorrect" spline is drawn with a separate pen, BadDataPen, which is red by default.
Hopefully, this will make it quite clear when series actually draw a spline, and when it does not.

Quote
I would suggest two properties ExtrapolatingXMin and ExtrapolatingXMax
I implemented a single option csoExtrapolate instead -- if you think there is a reason
to enable left and right extrapolation separately, please explain it.

WDB463

  • New Member
  • *
  • Posts: 11
Re: TAChart with spline series
« Reply #18 on: July 05, 2011, 07:00:14 pm »
The csoDrawFewPoints works but I would suggest a polynomial interpolations instead of a linear interpolation for three points so that the result is a curve.

The csoDrawUnordered has no effect at my tests. What is the background of this option?

The csoExtrapolate works fine but here I would suggest at least a separation to left and right side because especially at measurements only a extrapolation to the right side makes sense whereas the smaller values shall not be extrapolate while the chart starts from zero. Min- or MaxValues makes only sense when the extrapolation should stop before the Extend.XMax of the chart so that the extrapolating line do not touch the chart border. But the last is not really important.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart with spline series
« Reply #19 on: July 05, 2011, 08:15:29 pm »
Quote
The csoDrawFewPoints works but I would suggest a polynomial interpolations
I think I'll pass on this -- I hesitate to add yet another interpolation method
only for this single case.
However, my mind can be changed with a patch ;-)

Quote
The csoDrawUnordered has no effect at my tests. What is the background of this option?
Check "Random X" checkbox in the func demo to see the effect of this option.

Quote
The csoExtrapolate works fine but here I would suggest at least a separation to left and right
Ok, done so in r31569

WDB463

  • New Member
  • *
  • Posts: 11
Re: TAChart with spline series
« Reply #20 on: July 06, 2011, 02:51:29 pm »
Quote
I think I'll pass on this -- I hesitate to add yet another interpolation method
only for this single case.
However, my mind can be changed with a patch ;-)

Thats right, anyhow here one possible solution for a graph as a quadratic function f(x) = a * x^2 + b * x + c:

D = x1^2 * (x2 - x3) + x2^2 * (x3 - x1) + x3^2 * (x1 - x2)

A = (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)) / D
B = (y1 * (x3^2 - x2^2) + y2 * (x1^2 - x3^2) + y3 * (x2^2 - x1^2)) / D
C = (y1 * (x2^2 * x3 - x2 * x3^2) + y2 * (x3^2 * x1 - x3 * x1^2) + y3 * (x1^2 * x2 - x1 * x2^2)) / D

The extrapolation can be done with the slope at the min and max side:

f_min(x) = (2 * A * x_min + B) * x + A * x_min^2 + (B - 2 * A) * x_min + B - C
f_max(x) = (2 * A * x_max + B) * x + A * x_max^2 + (B - 2 * A) * x_max + B - C

 

TinyPortal © 2005-2018