Hi,
I have an TRoseSeries-chart and want to label the segments with labels. How can I position the labels with a larger margin and give them arrows so that every label points to its segment?
Is it possible to have a larger margin from the labels to the chart at the middle of the right and left side of the chart?
If I use Marks instead of the labels, the marks are positioned on my chart, the segments are partially hidden.
Kind regards
Peter
Labels on TRoseSeries
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Labels on TRoseSeries
Hi Peter,
It's a little bit tricky but possible with custom marks position as shown in the code snippet below. Also find attached the complete example project.peterlepan wrote: How can I position the labels with a larger margin and give them arrows so that every label points to its segment?
Code: Select all
procedure TForm1.CustomLabelsPosition;
const MarksOffset = 30;
var
i : Integer;
P : TPoint;
Radius : TPoint;
Angle : TChartValue;
begin
Radius:=TeePoint(Rose.XRadius + MarksOffset, Rose.YRadius + MarksOffset);
for i:=0 to Rose.Marks.Positions.Count-1 do
begin
Angle:=DegToRad(Rose.AngleValues[i]);
if Assigned(Rose.Marks.Positions[i]) then
begin
Rose.AngleToPos(Angle, Radius.X, Radius.Y, P.X, P.Y);
Rose.Marks.Positions[i].Custom:=True;
Rose.Marks.Positions[i].LeftTop.X:=P.X;
Rose.Marks.Positions[i].LeftTop.Y:=P.Y;
Rose.Marks.Positions[i].ArrowFrom.X:=P.X;
Rose.Marks.Positions[i].ArrowFrom.Y:=P.Y;
end;
end;
Rose.Repaint;
Rose.RefreshSeries;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Rose:=TRoseSeries.Create(Self);
Rose.FillSampleValues();
Rose.AngleLabels.Visible:=False;
Rose.Marks.Visible:=True;
//Rose.Marks.Transparent:=True;
Rose.Marks.Arrow.Visible:=True;
Chart1.ClipPoints:=False;
Chart1.View3D:=False;
Chart1.AddSeries(Rose);
Chart1.Draw;
CustomLabelsPosition;
Chart1.Draw;
end;
Yes, you can modify that depending on angle values, for example:peterlepan wrote: Is it possible to have a larger margin from the labels to the chart at the middle of the right and left side of the chart?
Code: Select all
procedure TForm1.CustomLabelsPosition;
const MarksOffset = 30;
var
i : Integer;
P : TPoint;
Radius : TPoint;
Angle : TChartValue;
begin
Radius:=TeePoint(Rose.XRadius + MarksOffset, Rose.YRadius + MarksOffset);
for i:=0 to Rose.Marks.Positions.Count-1 do
begin
Angle:=Rose.AngleValues[i];
if (Angle<45) or ((Angle>135) and (Angle<225)) or (Angle>315) then
begin
Radius.X:=Radius.X + 5;
Radius.Y:=Radius.Y + 5;
end;
Angle:=DegToRad(Angle);
if Assigned(Rose.Marks.Positions[i]) then
begin
Rose.AngleToPos(Angle, Radius.X, Radius.Y, P.X, P.Y);
Rose.Marks.Positions[i].Custom:=True;
Rose.Marks.Positions[i].LeftTop.X:=P.X;
Rose.Marks.Positions[i].LeftTop.Y:=P.Y;
Rose.Marks.Positions[i].ArrowFrom.X:=P.X;
Rose.Marks.Positions[i].ArrowFrom.Y:=P.Y;
end;
end;
Rose.Repaint;
Rose.RefreshSeries;
end;
- Attachments
-
- RoseCustomLabels.zip
- (2.77 KiB) Downloaded 586 times
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 10
- Joined: Thu Mar 06, 2014 12:00 am
Re: Labels on TRoseSeries
Hi Narcís,
thank you for your answer, but the solutions are really "tricky".
If I use labels and position them with a large margin, the right half of the chart is very nice, but look at the left side! Why are the labels on the left side so confused? Can't they look like the labels on the right side?
Have you an idea for this problem? I wish my labels look like the beams from the sun and the chart is the sun
Sincerely yours
Peter
thank you for your answer, but the solutions are really "tricky".
If I use labels and position them with a large margin, the right half of the chart is very nice, but look at the left side! Why are the labels on the left side so confused? Can't they look like the labels on the right side?
Have you an idea for this problem? I wish my labels look like the beams from the sun and the chart is the sun
Sincerely yours
Peter
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Labels on TRoseSeries
Hi Peter,
Thanks in advance.
Can you please attach a simple example project we can run "as-is" to reproduce the problem here?peterlepan wrote: If I use labels and position them with a large margin, the right half of the chart is very nice, but look at the left side! Why are the labels on the left side so confused? Can't they look like the labels on the right side?
Have you an idea for this problem?
peterlepan wrote: I wish my labels look like the beams from the sun and the chart is the sun
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 10
- Joined: Thu Mar 06, 2014 12:00 am
Re: Labels on TRoseSeries
Hi Narcís,
my problem was, that some of the labels where too long. Now, we have shorted the labels to three signs and it looks fine. The only caveat now is a little offset on top and bottom of the chart labels. Thats why the label text is left-aligned. Is it possible, to create an ideal cirlce from the labels?
With the new three-signed-labels, I need a legend beside the chart, with the complete label-text for the shortened label. How can I do this with the standard legend? Can I create a new invisible series with the long label texts and the three sign short labes? Or have I to print the legend by myself in the AfterDraw event handler?
Thank you
Peter
my problem was, that some of the labels where too long. Now, we have shorted the labels to three signs and it looks fine. The only caveat now is a little offset on top and bottom of the chart labels. Thats why the label text is left-aligned. Is it possible, to create an ideal cirlce from the labels?
With the new three-signed-labels, I need a legend beside the chart, with the complete label-text for the shortened label. How can I do this with the standard legend? Can I create a new invisible series with the long label texts and the three sign short labes? Or have I to print the legend by myself in the AfterDraw event handler?
Thank you
Peter
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Labels on TRoseSeries
Hi Peter,
I'm not sure about what you mean here. Could you please attach a simple example project we can run "as-is" to reproduce the problem here?peterlepan wrote: Is it possible, to create an ideal cirlce from the labels?
You can have the standard legend with the full text. You could shorten labels in the OnGetMarkText event. Alternatively, you could do something similar in the OnGetLegendText event. Another option is using the Custom Legend tool. You'll find an example at All Features\Welcome!\Tools\Custom Legend in the new features demo, available at TeeChart's program group.peterlepan wrote: With the new three-signed-labels, I need a legend beside the chart, with the complete label-text for the shortened label. How can I do this with the standard legend? Can I create a new invisible series with the long label texts and the three sign short labes? Or have I to print the legend by myself in the AfterDraw event handler?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |