7

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 chart Bad: 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.

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • 2
    I'd check what would the other computer report for LOGPIXELSX / LOGPIXELSY. – Sertac Akyuz Apr 17 '14 at 22:33
  • @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 Apr 17 '14 at 22:42
  • @Mason - Of course what I meant was to call GetDeviceCaps. – Sertac Akyuz Apr 17 '14 at 22:46
  • @SertacAkyuz: Just tested it with GetDeviceCaps, and both systems report 96/96. – Mason Wheeler Apr 17 '14 at 23:12
  • @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 Apr 17 '14 at 23:15
  • @SertacAkyuz: I'm not sure I follow. With both systems having the same resolution and the same DPI, why would one come out stretched and the other not? – Mason Wheeler Apr 17 '14 at 23:22
  • @Mason - Well, we didn't know if they had the same DPI then. I was just trying to explain my reasoning in suggesting to look at DPI. It's not the issue alright, now we know it., – Sertac Akyuz Apr 17 '14 at 23:25
  • If it gives anyone an idea: tool tips on both shots are identical, f.i. the '135' is 31x17. Upper graphic's bounds are 192x192 (just the pie). Lower graphic's bounds are 194x162. – Sertac Akyuz Apr 17 '14 at 23:35
  • Would it help if we had your code – David Heffernan Apr 18 '14 at 06:55
  • Do you have any idea why your chart lines are so "hairy"? – mg30rg Apr 18 '14 at 07:48
  • @mg30rg: Because TeeChart apparently doesn't antialias the pie chart lines. – Mason Wheeler Apr 18 '14 at 10:17
  • @MasonWheeler which TeeChart version are you using? Have you tried with the latest maintenance release available? Which screen resolutions show the problem? – Narcís Calvet Apr 22 '14 at 11:01

1 Answers1

7

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;
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477