7
votes

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.

1
I'd check what would the other computer report for LOGPIXELSX / LOGPIXELSY. - Sertac Akyuz
@SertacAkyuz: Those are constants defined in Windows.pas. How would another system report different values when these are constants that get set in stone at compile-time? - Mason Wheeler
@Mason - Of course what I meant was to call GetDeviceCaps. - Sertac Akyuz
@SertacAkyuz: Just tested it with GetDeviceCaps, and both systems report 96/96. - Mason Wheeler
@Mason - Thanks for testing. I was suspecting a non-native (and stretched) resolution on the other monitor (to match the resolution with yours). With a possible assumption of square pixels in Steema code, this might explain the issue. - Sertac Akyuz

1 Answers

7
votes

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;