Hello guys.
I have a pie-chart, and the size of the component varies with the form's size (i.e. the user can change his window's size).
The problem is that sometimes the pie can become an elliptic and not a circle - if the width is larger than the height, etc. (well, it actually includes a legend, so it is a circle when the width is larger).
Is there a way I can force the graph to be a real circle, even if I'll have some "Dead" screen not used?
I'm using V7, Pro, with delphi 2005.
Thanks,
Ron.
Force pie-graph to be "circle"
How to make TPieSeries circular in widescreen
The TPieSeries::Circled proerty does not work as expected in widescreen modes as it produces non circular pies. Here is a work around which makes a pie XRadius and YRadius the same. Its in C++
1) Dervive a class from TPieSeries
2) Overide its DoBeforeDrawValues procedure as follows:
// Bug Fix E:
void __fastcall ITPieSeries::DoBeforeDrawValues ()
{
TPieSeries::DoBeforeDrawValues ();
if (Circled)
{
MakeCircled ();
}
}
void ITPieSeries::MakeCircled ()
{
int iDiff = abs (YRadius - XRadius);
if (YRadius < XRadius)
{
CircleRect.Left += iDiff;
CircleRect.Right -= iDiff;
}
else if (YRadius > XRadius)
{
CircleRect.Top += iDiff;
CircleRect.Bottom -= iDiff;
}
AdjustCircleRect ();
CalcRadius ();
}
1) Dervive a class from TPieSeries
2) Overide its DoBeforeDrawValues procedure as follows:
// Bug Fix E:
void __fastcall ITPieSeries::DoBeforeDrawValues ()
{
TPieSeries::DoBeforeDrawValues ();
if (Circled)
{
MakeCircled ();
}
}
void ITPieSeries::MakeCircled ()
{
int iDiff = abs (YRadius - XRadius);
if (YRadius < XRadius)
{
CircleRect.Left += iDiff;
CircleRect.Right -= iDiff;
}
else if (YRadius > XRadius)
{
CircleRect.Top += iDiff;
CircleRect.Bottom -= iDiff;
}
AdjustCircleRect ();
CalcRadius ();
}