Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a graph in a panel

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
GB
Hi,
I need to take the print out of a graph which is in a panel. First i need to take the print preview report and to take the print out. Can anyone help me with that?

Many Thanks,
Sanjna...
 
As far as printing the tchart goes, it's simple

There are a number of Print methods that you can use with a TChart

for exaple if you wanted to print a full page landscape graph you would use the code below.

Printer.Orientation := poLandscape;
Chart1.PrintRect(Rect(0,0,Printer.PageWidth-1,Printer.PageHeight-1));

(remember to add Printers to the uses clause)

If you read the help file in Delphi it explains what all the other print functions do.

As for doing a print preview there is a method of TChart called

PrintPartialCanvasToScreen

This however doesn't seem to work in Delphi 5.


Hope this helps

Andrew


 
Thank you so much for your help Andrew.. I tried to do the same as u , but unfortunately it prints only the x, y axis. In order to draw the graph i have used a seperate unit. Do u have any idea how i can print the graph?

Many thanks for u r help!
Sanjna...
 
Umm am a bit confused? Do you want the x and the y axis printed? or just the line/points etc of the graph?


THe above code should print everything out on the TChart. Have you actually drawn the graph onto the TChart before you print it?

Try these as well.

Chart1.PrintLandscape;
Chart1.Print;
Chart1.PrintPortrait;

Also what version of Delphi are you using.

Andrew
 
Hi Andrew,

Well I want to print the whole graph ( including x, y axis and the curve ) . In my project, i have my string grid to enter values for x, y axis and the graph will be drawn accroding to the entered x, y values in a panel. I used a seperate unit in my project to draw the graph. but when i give the print command as u suggested it does not print the curve. instead it draws only the x, y axis.

By the way i 've got Delphi 6.

I am waiting for your reply..........
Thank you so much for your help :)

Sanjna...
 
I have done this on Delphi 5 and Delphi 7 and it prints everything out as expected?

Have you tried

Chart1.Print;

This will print out what you see on the Chart.



Have you got more than 1 chart on the form. Are you trying to print the correct chart?

If this doesn't work try setting up a new project with a TChart, set up a graph and just try printing that, see if it works then.




Andrew



 
Hi Andrew,

Thank you so much for your help. I do have only one chart on my form. but Chart1.Print does not print the curve in my graph. I will try to set up a new project and see how it works.

Thanks for your help.
Sanjna.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top