Search code examples
c++c++builderteechart

Horizontal distance between points drawn


I try to draw a normal XY plot using a TChart (TeeChart) component in Embarcadero RAD Studio. When I add new points that have evenly spaced x values, e. g.

x: 1  2  3  4  5
y: 10 20 5  8  100

everything is drawn OK.

But when I add points that are unevenly spaced on the x axis, e. g.

x: 1  2   100 120 150
y: 10 20  5   8   100

the chart is drawn in such a way that the points still have the same distance between each other on the x axis. That is the distance between points 1-2 is the same as between 2-100. Is it possible to draw a proportional XY plot?

This is my sample code:

Series1->Add(10, 1);
Series1->Add(20, 2);
Series1->Add(5, 100);
Series1->Add(8, 120);
Series1->Add(100, 150);

The style of Series1 is Line.


Solution

  • Instead of calling Add, you need to call AddXY to add XY points.