Printing Charts


Q: Coloured Axis Grid lines not printing on HP Lajerset printers.


Original HP printer drivers found in Windows NT 4 have this bug. Try installing a newer version of the HP printer ( www.hp.com ) or setting the grid line Pen style to solid and the Pen color to black.

DELPHI CODE:

Chart1.BottomAxis.Grid.Style:=psDot;
Chart1.BottomAxis.Grid.Width:=0;  
{ <-- try also with 1, 2, etc } 
Chart1.BottomAxis.Grid.Color:="clBlack;" 

CBUILDER CODE:

Chart1->BottomAxis->Grid->Style=psDot;
Chart1->BottomAxis->Grid->Width=0;  
// <-- try also with 1, 2, etc

Chart1->BottomAxis->Grid->Color=clBlack;

 

SPECIAL NOTE for Windows 2000 users:

HP just released new updated printer drivers for HP LJ (July 2000). It seems these printer drivers don't exhibit this bug. Please check the following URL for availablility of the latest HP LJ printer drivers : http://www.hp.com/cposupport/printers/support_doc/bpl07374.html#P580_28842


Q: How can I print a very large line chart in several pages?

First you need to determine how many points you want per page.  Then you can use the Chart1.MaxPointsPerPage property to split the whole chart in several pages. Finally, you can use a loop to print all the pages using the NumPages and Page properties.

DELPHI CODE:

Chart1.MaxPointsPerPage:= 100;
for t:=1 to Chart1.NumPages do
begin
  Chart1.Page:=t;
  Chart1.PrintLandscape;
end;

CBUILDER CODE:

Chart1->MaxPointsPerPage=100;
for (int t=1;t<=Chart1->NumPages;t++)
{
  Chart1->Page=t;
  Chart1->PrintLandscape();
}

Q: How can I print charts to monochrome printers ?


For each different Series type there is a solution. If your printer has good "grey-scale" printing output, you might just need to select
good colors for each different level of gray. The best solution, though, is to select a different Brush.Style for each Series.  For example, the Pie Series has a "UsePatterns" property which plots each Pie slice using a different pattern style.

Windows provides only 6 different patterns (vertical, horizontal, diagonal, etc) . Now in TeeChart Pro 4.0 you can use the Brush.Bitmap property to fill points using your custom "patterns" in bitmap (picture) format. Thousands of freeware patterns can be found at many internet web sites (marble,wood, water, iron, etc).


Q: I want printed Charts to look the same on different screen resolutions
and chart sizes. How ?


By default, TeeChart prints charts in "wysiwyg" style ( What You See Is What You Get ). This means if your chart is bigger, your printed chart will have Font Sizes smaller. If you print the same chart on another PC with a different screen resolution, the printed output will reflect so.

To avoid any scaling, and to make the printed chart to look always the same, you can just create a Delphi's (or C++ Builder) TMetafile object, draw the Chart onto it, and then print the resulting TMetafile image. You can also use a TBitmap image instead of a TMetafile. Some printers have bugs when printing metafiles depending on the Windows version, printer driver and so on. Creating the metafile image and sending it to the Printer.Canvas gives you total control on the Chart and paper dimensions.

See Delphi's (or C++ Builder) documentation about TMetafile and TPrinter objects.

DELPHI CODE:

var Meta      :TMetafile;
    tmpH,tmpW : LongInt;
begin
  Meta:=Chart1.TeeCreateMetafile(True,Rect(0,0,tmpW,tmpH));
  try
    Printer.BeginDoc;
    try
      Printer.Canvas.StretchDraw(Rect(1000,1000,2000,2000)
       ,Meta);
    finally
      Printer.EndDoc; 
    end;
  finally
    Meta.Free;
  end;
end;

CBUILDER CODE:

{
  int tmpW=Chart1->Width;
  int tmpH=Chart1->Height;
  TMetafile *tmpMeta=Chart1->TeeCreateMetafile(true,Rect(0,0,tmpW,tmpH));
  try
  {
     Printer()->BeginDoc();
     try
     {
        Printer()->Canvas->StretchDraw(Rect(1000,1000,2000,2000),tmpMeta);
     }
     __finally
     {
        Printer()->EndDoc();
     }
  }
  __finally
  {
  delete tmpMeta;
  }

}

Q: Printing rotated labels 90 degree might show them wrong

"Vertical X-Axis labels spacing is not consistent when printed. The space
between the end of the label (90 degrees from horiz) and the axis ticks is not consistent from one printer to another. It looks fine on the PC screen.  We currently have to manually set this because it is too close on the HP LJ4."

This problem happens mostly only in Delphi 1 16bit.

Yes. Ratio width to height in paper printer units should be the same than screen for rotated labels to show at a good position. It happens when this ratio is different, Windows "stretches" the metafile, so the bottom coordinate of the axis label is "moved" far more bottom than
it should.

Ratio = Chart1.ChartWidth / Chart1.ChartHeight

There is an example of "proportional printing" at www.steema.com technical page. (The "printing better" example). It might work fine with your printer. HP printer drivers that come with NT4 are buggy, and HP has replacements at their www site.

See also this FAQ question:
"I want printed Charts to look the same on different screen resolutions and chart sizes. How ? "


Q: Printing with Delphi 1 does not clip points


Yes.
Windows 16bit does not allow clipping when printing using metafiles.

Workarounds are to use a TBitmap image for printing, or using Windows 95B (OSR2) and setting the TeeChart clipping global variables to True.

Clipping also depends on your printer model and driver. Some printer drivers do not implement metafile clipping or implement it buggy.

DELPHI CODE:

Chart1.ClipPoints:=True;
TeeClipWhenPrinting:=True;
TeeClipWhenMetafiling:=True;
Chart1.Print;

CBUILDER CODE:

Chart1->ClipPoints=true;
TeeClipWhenPrinting=true;
TeeClipWhenMetafiling=true;
Chart1->Print();

Q: Using PrintPartial to print more than one chart on the same page leaves wrong font and backcolor.


This bug has been fixed in TeeChart Pro 4.0

You can overcome this by resetting the Printer.Canvas.Font color and size after printing each chart.

Mr.Glenn Bennes ( gjbenes@infocompii.com ) comments:

"I believe I originally reported the font problem. My solution was to print the problem chart onto its own metafile first and then copy that meta file onto my print canvas. That way the top and left print coordinates were  0,0 instead of somewhere at the bottom of the page. The chart was being confused because the canvas size was much different than the chart's print area. This messed up the font scaling."
 

DELPHI CODE:

...
Chart1.PrintPartial...
Printer.Canvas.Font.Color:=clWhite;
Printer.Canvas.Font.Size:=8;
Chart2.PrintPartial...
...

CBUILDER CODE:

...
Chart1->PrintPartial...
Printer()->Canvas->Font->Color=clWhite;
Printer()->Canvas->Font->Size=8;
Chart2->PrintPartial...
...


Q: When printing a chart, using the PrintPartial command, the chart is sending som kind of scale information to the printer. This scaling is not reseted back. A solution ?

Chart PrintPartial method manipulates the printer DC mapping mode and does not reset it to what it was before. So what you can do is save the current mapping mode before printing:

DELPHI CODE:

MapMode := GetMapMode(Printer.Handle);

and then restore it back after each chart printed:

TempChart.PrintPartial(Rect(0, Y, PageWidth - 1, Y + GraphHeight - 1));
SetMapMode(Printer.Handle, MapMode);

CBUILDER CODE:

...

   int MapMode=GetMapMode(Printer()->Handle);
   TempChart->PrintPartial(Rect(0,0,2000,2000));
   SetMapMode(Printer()->Handle,MapMode);
   ...

Q: Printing problems with Windows NT and Windows 2000

Many of the Windows NT and Windows 2000 drivers are noted for having problems with  colored lines and / or colored text. There is a little printer test utility available at www.pcpav.com.
Yo can download it from the following URL: http://www.pcpav.com/download-index.html.  Try that and see what it reports. The test report will attempt to print  all of the different type of problems that seem to be recurring issues
with Printers / Printer Driver / Operating System conficts. Now, one possible fix - use an alternate Printer Driver on the NT system.