Page 1 of 1
Labels on TRoseSeries
Posted: Wed Jun 10, 2015 1:54 pm
by 16468660
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.
- TRoseSeries with labels
- rose.jpg (257.53 KiB) Viewed 9838 times
- marks instead of the labels
- marks.jpg (237.79 KiB) Viewed 9825 times
Kind regards
Peter
Re: Labels on TRoseSeries
Posted: Thu Jun 11, 2015 8:57 am
by narcis
Hi Peter,
peterlepan wrote:
How can I position the labels with a larger margin and give them arrows so that every label points to its segment?
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.
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;
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?
Yes, you can modify that depending on angle values, for example:
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;
Re: Labels on TRoseSeries
Posted: Fri Jun 12, 2015 12:55 am
by 16468660
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
- rose_label.jpg (291.85 KiB) Viewed 9781 times
Sincerely yours
Peter
Re: Labels on TRoseSeries
Posted: Fri Jun 12, 2015 9:03 am
by narcis
Hi Peter,
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?
Can you please attach a simple example project we can run "as-is" to reproduce the problem here?
peterlepan wrote:
I wish my labels look like the beams from the sun
and the chart is the sun
Thanks in advance.
Re: Labels on TRoseSeries
Posted: Fri Jun 12, 2015 3:33 pm
by 16468660
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
Re: Labels on TRoseSeries
Posted: Mon Jun 15, 2015 7:48 am
by narcis
Hi Peter,
peterlepan wrote:
Is it possible, to create an ideal cirlce from the labels?
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:
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?
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.