Hello,
I am using the latest TChart version and I have trouble to adjust marks text placement when YMandatory is set to false. If I set YMantatory to true then then I can control the margin between the mark point and text by adjusting the arrow length. How can I adjust the text position and what exactly is the YMantatory property?
Regards
Point series and marks text position
Point series and marks text position
- Attachments
-
- Project1.zip
- (5.03 KiB) Downloaded 1052 times
Re: Point series and marks text position
Indeed the ArrowLength is only applied when YMandatory is true:
This was probably made to avoid problems. I see it's like this since TeeChart v6 (in 2003).
The YMandatory property controls whether the series is "horizontal" or "vertical".
Look at the SetHorizontal method:
The SetHorizontal method is only called for the "horizontal" series (such as THorizLineSeries and THorizAreaSeries). Otherwise, the YMandatory property is initialized at the TChartSeries constructor:
Why are you manually setting YMandatory to false?
Code: Select all
Procedure TCustomSeries.DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition);
//...
if YMandatory then
Marks.ApplyArrowLength(APosition);
//...
The YMandatory property controls whether the series is "horizontal" or "vertical".
Look at the SetHorizontal method:
Code: Select all
procedure TChartSeries.SetHorizontal;
begin
MandatoryValueList:=XValues;
NotMandatoryValueList:=YValues;
YMandatory:=False;
end;
Code: Select all
Constructor TChartSeries.Create
//...
FX:=TChartValueList.Create(Self,TeeMsg_ValuesX);
FX.FOrder:=loAscending;
NotMandatoryValueList:=FX;
FY:=TChartValueList.Create(Self,TeeMsg_ValuesY);
MandatoryValueList:=FY;
YMandatory:=True;
//...
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Point series and marks text position
Hello Yeray,
I try to create a band between 2 PointSeries, for each PointSeries I create LineSeries that is a smoothing function of the associated PointSeries. After trial and error I found out that setting the Y mandatory to false helps create "correct" smoothing lines
Thank you very much for the support!
Regards
I try to create a band between 2 PointSeries, for each PointSeries I create LineSeries that is a smoothing function of the associated PointSeries. After trial and error I found out that setting the Y mandatory to false helps create "correct" smoothing lines
Thank you very much for the support!
Regards
Re: Point series and marks text position
Hello,
Check out this simple example:
I only had to exchange the X and Y values between the source point series and the horizline series:
Note I've used the Smoothed property of the LineSeries above. If you want to use a SmoothingFunction (ie to control the Factor), you'll need two extra HorizLine series. Here an example (I'm not showing a screenshot because it looks exactly as above):
Check out this simple example:
I only had to exchange the X and Y values between the source point series and the horizline series:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var point: array[0..1] of TPointSeries;
horizLine: array[0..1] of THorizLineSeries;
i, j: Integer;
begin
Chart1.View3D:=False;
Chart1.Legend.Hide;
Chart1.Gradient.Visible:=False;
Chart1.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Axes.Left.Increment:=1;
for i:=0 to 1 do
begin
point[i]:=TPointSeries(Chart1.AddSeries(TPointSeries));
with point[i] do
begin
Pointer.Size:=3;
Marks.Visible:=True;
Marks.Transparent:=True;
Marks.ArrowLength:=10;
Marks.Arrow.Visible:=False;
AddXY(random*10-5, 0);
for j:=1 to 9 do
AddXY(XValue[j-1] + random*10-5, j);
end;
horizLine[i]:=THorizLineSeries(Chart1.AddSeries(THorizLineSeries));
with horizLine[i] do
begin
Smoothed:=True;
Color:=point[i].Color;
for j:=0 to point[i].Count-1 do
AddXY(point[i].XValue[j], point[i].YValue[j]);
end;
end;
with TSeriesBandTool(Chart1.Tools.Add(TSeriesBandTool)) do
begin
Brush.BackColor:=clGray;
Transparency:=70;
Series:=horizLine[0];
Series2:=horizLine[1];
end;
end;
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var point: array[0..1] of TPointSeries;
horizLine: array[0..1] of THorizLineSeries;
smoothLine: array[0..1] of THorizLineSeries;
smoothFunc: array[0..1] of TSmoothingFunction;
i, j: Integer;
begin
Chart1.View3D:=False;
Chart1.Legend.Hide;
Chart1.Gradient.Visible:=False;
Chart1.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Axes.Left.Increment:=1;
for i:=0 to 1 do
begin
point[i]:=TPointSeries(Chart1.AddSeries(TPointSeries));
with point[i] do
begin
Pointer.Size:=3;
Marks.Visible:=True;
Marks.Transparent:=True;
Marks.ArrowLength:=10;
Marks.Arrow.Visible:=False;
AddXY(random*10-5, 0);
for j:=1 to 9 do
AddXY(XValue[j-1] + random*10-5, j);
end;
horizLine[i]:=THorizLineSeries(Chart1.AddSeries(THorizLineSeries));
with horizLine[i] do
begin
//Smoothed:=True;
Color:=point[i].Color;
for j:=0 to point[i].Count-1 do
AddXY(point[i].XValue[j], point[i].YValue[j]);
Active:=False;
end;
smoothFunc[i]:=TSmoothingFunction.Create(Self);
smoothFunc[i].Factor:=10;
smoothLine[i]:=THorizLineSeries(Chart1.AddSeries(THorizLineSeries));
with smoothLine[i] do
begin
Color:=horizLine[i].Color;
SetFunction(smoothFunc[i]);
DataSource:=horizLine[i];
end;
end;
with TSeriesBandTool(Chart1.Tools.Add(TSeriesBandTool)) do
begin
Brush.BackColor:=clGray;
Transparency:=70;
Series:=smoothLine[0];
Series2:=smoothLine[1];
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Point series and marks text position
Thank you, I will take a closer look!