Page 1 of 1
Drawing on a Rose Chart
Posted: Tue Jun 17, 2014 8:01 am
by 16568901
Hi,
Is it possible to draw a "*" or some other character at a given angle and radius on a Rose Chart?
I seem to recall doing something like this many years ago (not with Rose but with a bar chart or pie chart) with TeeChart but I can't find where I did it.
Re: Drawing on a Rose Chart
Posted: Tue Jun 17, 2014 2:25 pm
by yeray
Hello,
Here you have a simple example about how to do this.
Note I've extracted the CalcXYPosition method from TPolarSeries class. You can probably simplify this method while still fitting your needs.
Code: Select all
const
TeePiStep:Double = Pi/180.0;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var Angle, Value: Double;
X, Y: Integer;
tmp, AxisXRadius, AxisYRadius: Integer;
begin
Angle:=40;
Value:=500;
tmp:=Series1.CirclePen.HalfWidth;
AxisXRadius:=Series1.XRadius-tmp;
AxisYRadius:=Series1.YRadius-tmp;
CalcXYPosition(Series1, Angle, Value, AxisXRadius, Series1.GetHorizAxis, X, tmp);
CalcXYPosition(Series1, Angle, Value, AxisYRadius, Series1.GetVertAxis, tmp, Y);
Chart1.Canvas.Font.Color:=clRed;
Chart1.Canvas.TextOut(X, Y, '*');
end;
procedure TForm1.CalcXYPosition(const ASeries: TPolarSeries; const XValue, YValue: TChartValue;
ARadius: Integer; Axis: TChartAxis; out X, Y: Integer);
Function CalcLogRadius(const tmpDif:Double):Double;
var IAxisLogSizeRange : Double;
ILogMin : Double;
ILogMax : Double;
begin
ILogMax:=ln(Axis.Maximum);
if Axis.Minimum<=0 then
ILogMin:=0
else
ILogMin:=ln(Axis.Minimum);
IAxisLogSizeRange:=ARadius/(ILogMax-ILogMin);
if Axis.Inverted then
result:=Round((ILogMax-ln(tmpDif))*IAxisLogSizeRange)
else
result:=Round((ln(tmpDif)-ILogMin)*IAxisLogSizeRange);
end;
var tmp : Double;
tmpDif : Double;
tmpAtEnd : Boolean;
tmpRadius : Double;
begin
With Axis do tmp:=Maximum-Minimum;
if Axis.Inverted then
tmpDif:=Axis.Maximum-YValue
else
tmpDif:=YValue-Axis.Minimum;
if Axis.Logarithmic then tmpAtEnd:=tmpDif<=0
else tmpAtEnd:=tmpDif<0;
if (tmp=0) or tmpAtEnd then
begin
X:=ASeries.CircleXCenter;
Y:=ASeries.CircleYCenter;
end
else
begin
if Axis.Logarithmic then
tmpRadius:=CalcLogRadius(tmpDif)
else
tmpRadius:=tmpDif*ARadius/tmp;
ASeries.AngleToPos(TeePiStep*XValue,tmpRadius,tmpRadius,X,Y);
end;
end;
Re: Drawing on a Rose Chart
Posted: Tue Jun 17, 2014 3:04 pm
by 16568901
Many thanks - worked as needed once I adjusted for my own code
Now to sit down and examine what actually happens. Great support!