Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can cause a pie chart to come out "squished"?

I have a pie chart, created with TeeChart, that looks just fine on the system I develop on, but when I run it on a different machine, the "pie" comes out all squished into an oval shape instead of being circular.

I've ensured that the Circled property (which should ensure that what's drawn is always a circle, not an ellipse,) on the TPieSeries is set True and does not get changed anywhere.

I checked to make sure that this isn't an artifact of different screen resolutions. It's not; the other system is on the same resolution as my dev box.

The other system had Aero turned off. I tested things by turning Aero off on my dev box, and the charts did not come out squished.

At this point I'm basically out of ideas. Does anyone know what can cause a pie chart that's set Circled = true to draw as an oval rather than a circle?

Good: Good pie chartBad: Bad pie chart

This is the exact same program, working off the exact same data, at the exact same screen resolution, on two different computers.

EDIT: As discussed in comments, I tested this and found that both systems have not only the same resolution, but also the same DPI.

like image 448
Mason Wheeler Avatar asked Apr 17 '14 22:04

Mason Wheeler


1 Answers

After a bunch of debugging and digging into the issue, it turns out this is happening because the TeeChart code is calling GetDeviceCaps with the HORIZSIZE and VERTSIZE parameters, to determine the physical size of the pixels on screen and adjust the circle's bounding rect accordingly. Unfortunately, this call is only valid on a printer, and not on a display device, and it has known issues on Windows 7, which both of the systems in question are using. I've reported the issue to Steema. Hopefully they can get it fixed.

UPDATE: Got a response from Steema, in which they acknowledged the problem and provided a workaround. Copying it here in case anyone else runs into the problem:

An alternative that allows you workaround the problem is to customize the Pie Radius using, perhaps, the height of the Chart rectangle to govern the dimension you need.

Eg:

procedure TForm9.Button1Click(Sender: TObject);
var cHeight : Integer;
begin
  cHeight := Round((Chart1.ClientRect.Bottom -  Chart1.ClientRect.Top) * 0.80); //80%

  series1.CustomXRadius := cHeight div 2;
  series1.CustomYRadius := series1.CustomXRadius;
end;
like image 120
Mason Wheeler Avatar answered Sep 22 '22 16:09

Mason Wheeler