Chart printing questions

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Chart printing questions

Post by bairog » Sat Dec 29, 2018 6:45 am

Hello.
I'm using TeeChart Pro 4.2018.12.17 and I have a form with chart that looks somewhat like the following:
Image
Chart title (it will be visible only at print preview) has exact the same font as labels and textboxes on the top (Calibri, 12pt).
Axes lines have width = 2 while ticks, dashed grid lines and wall lines (top and right) have width = 1.
And I have some questions regarding printing:
  1. Initial zoom for print preview is too small - it looks somewhat like:
    Image
    Is there a way to change that value?
  2. If we zoom in - we can see that ticks and walls are ok, but dashed grid lines are too thick (they have the same width like axes lines) - you can open the following image in another tab to zoom in and see what exactly I'm talking about:
    Image
    Checking "Quality" checkbox changes nothing
  3. As you can see while printing I'm adding labels and textboxes on the top:

    Code: Select all

    private void tChart1_ChartPrint(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
    var temp = new Bitmap(panel1.Width, panel1.Height);
    panel1.DrawToBitmap(temp, new Rectangle(0, 0, panel1.Width, panel1.Height));
    var chartRect = (sender as Steema.TeeChart.ChartPrintJob).ChartRect;
    e.Graphics.DrawImage(temp, chartRect.Left + (chartRect.Width - temp.Width) / 2, chartRect.Top - temp.Height);
    }
    Chart title font is looking bigger than font for labels and textboxes (despite of being the same - Calibri, 12pt).
    Looks like that is because chart scales to fit the page (and so the chart title font does).
    So how can I get scaling coefficient (or coefficients for X/Y if they are not he same) by which I will need to multiply the font size for labels and textboxes?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Chart printing questions

Post by Christopher » Mon Dec 31, 2018 8:25 am

Hello,

in order to facilitate the resolution of defects which occur in more complex situations, such as your issue with printing, we ask our clients to produce a Minimal, Complete, and Verifiable example ('mcve') with which we can reproduce the issue here (an mcve is defined on this page) - would you please be so kind as to produce an mcve for us in this case?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Re: Chart printing questions

Post by bairog » Tue Jan 01, 2019 5:49 pm

Christopher wrote:
Mon Dec 31, 2018 8:25 am
Hello,

in order to facilitate the resolution of defects which occur in more complex situations, such as your issue with printing, we ask our clients to produce a Minimal, Complete, and Verifiable example ('mcve') with which we can reproduce the issue here (an mcve is defined on this page) - would you please be so kind as to produce an mcve for us in this case?
I've uploaded sample application here

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Chart printing questions

Post by Marc » Wed Jan 02, 2019 5:09 pm

Hello,

Thanks for uploading the demo project.

Re. 1. Zoom.
The property forms part of the preview and is private. We can look to opening up the Previewer to code, so that some defaults can be set before opening it.

Re 2. Grid Pen
With respect to Axis Grid. It seems that 'special' line pens, dash, dot etc, scale differently to solid lines. A solid line appears to keep its dimension rather better, we'll look into options.

Re. 3. Title/Label fonts.
With respect to Title and Axis Label fonts: Not sure about that; they are different when opened in the demo here (header Calibri, axis labels, Verdana). You can guarantee that they'll come out the same when opening the Preview if you make one a copy of the other.
eg.

Code: Select all

tChart1.Header.Font = tChart1.Axes.Left.Labels.Font;
tChart1.Printer.Landscape = true;
tChart1.Printer.Preview();
We'll check through the pending points; if it looks possible to enable the preview functionality we'll do so for an upcoming release.

Regards,
Marc Meumann
Steema Support

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Re: Chart printing questions

Post by bairog » Wed Jan 02, 2019 5:19 pm

Marc wrote:
Wed Jan 02, 2019 5:09 pm
Re 2. Grid Pen
With respect to Axis Grid. It seems that 'special' line pens, dash, dot etc, scale differently to solid lines. A solid line appears to keep its dimension rather better, we'll look into options.
Regarding dash line: if you copy-paste print-previewed chart to any image editor and zoom it in - you can see that:
  1. Dashes is printed two times thicker than should be (it is like left axis line, but should be like top and right wall line)
  2. Space between dashes is printed with thin line (like top and right wall line)- it should be empty
Marc wrote:
Wed Jan 02, 2019 5:09 pm
Re. 3. Title/Label fonts.
With respect to Title and Axis Label fonts: Not sure about that; they are different when opened in the demo here (header Calibri, axis labels, Verdana).
I mean chart title font ("TeeChart title") and font for label above chart("Some text"). They are both Calibri, 12pt. But while print preview they look different (chart title font is bigger). I supposed that it is because of chart scaling (chart is enlarging to fit a sheet of paper) - and I asked how can I calculate chart scale coefficient (X and Y).
Last edited by bairog on Wed Jan 09, 2019 6:39 am, edited 1 time in total.

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Chart printing questions

Post by Marc » Fri Jan 04, 2019 12:34 pm

Hello,

Re.
I mean chart title font ("TeeChart title") and font for label above chart("Some text"). They are both Calibri, 12pt. But while print preview they look different (chart title font is bigger). I supposed that it is because of chart scaling (chart is enlarging to fit a sheet of paper) - and I asked how can I calculate chart scale coefficient (X and Y).
Ok, I'd misunderstood. Yes, very difficult to match up the outcome of the font size if you're working with a bitmap that will be stretched/resized according to where it's output.

There are alternative techniques though if you wish to output shapes and text to the Chart, You could use the OnAfterDraw method. This limits the area to plot to that which is sizewise available before printing but in this example an adjustment is made to the top margin on the chart before printing.

eg.
call with

Code: Select all

void myPrintMethod()
//....
double oldTopMargin = tChart1.Panel.MarginTop;
tChart1.Panel.MarginTop = 10; //make space for new content
tChart1.Printer.Preview();
tChart1.Panel.MarginTop = oldTopMargin; //reset Margin
//....
}

private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
	if (tChart1.Printing)
	{
		string myText = label1.Text;

		Rectangle myRect = new Rectangle(0, 0, panel3.Width, panel3.Height);

		g.Brush.Color = panel3.BackColor;
		g.Rectangle(new Rectangle(g.ChartXCenter-(myRect.Width/2), 0,myRect.Width,myRect.Height));
		g.Font = tChart1.Header.Font;
		g.TextOut((int)(g.ChartXCenter - (g.TextWidth(myText) / 2)), (int)((myRect.Height/2) - (g.TextHeight("T")/2)), myText);
	}
}
Regards,
Marc
Steema Support

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Re: Chart printing questions

Post by bairog » Wed Jan 09, 2019 7:36 am

Marc wrote:
Fri Jan 04, 2019 12:34 pm
Yes, very difficult to match up the outcome of the font size if you're working with a bitmap that will be stretched/resized according to where it's output.

There are alternative techniques though if you wish to output shapes and text to the Chart, You could use the OnAfterDraw method. This limits the area to plot to that which is sizewise available before printing but in this example an adjustment is made to the top margin on the chart before printing.
Thx, that code works like a charm (both for Album and Landscape orientations).

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Re: Chart printing questions

Post by bairog » Fri Jul 19, 2019 9:50 am

Marc wrote:
Wed Jan 02, 2019 5:09 pm
Re. 1. Zoom.
The property forms part of the preview and is private. We can look to opening up the Previewer to code, so that some defaults can be set before opening it.

Re 2. Grid Pen
With respect to Axis Grid. It seems that 'special' line pens, dash, dot etc, scale differently to solid lines. A solid line appears to keep its dimension rather better, we'll look into options.
Hello again.
Any progress on this two moments for today?
Thank you.

Post Reply