Page 1 of 1
Chart printing questions
Posted: Sat Dec 29, 2018 6:45 am
by 15685014
Hello.
I'm using TeeChart Pro 4.2018.12.17 and I have a form with chart that looks somewhat like the following:
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:
- Initial zoom for print preview is too small - it looks somewhat like:
Is there a way to change that value?
- 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:
Checking "Quality" checkbox changes nothing
- 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?
Re: Chart printing questions
Posted: Mon Dec 31, 2018 8:25 am
by Christopher
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?
Re: Chart printing questions
Posted: Tue Jan 01, 2019 5:49 pm
by 15685014
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
Re: Chart printing questions
Posted: Wed Jan 02, 2019 5:09 pm
by Marc
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
Re: Chart printing questions
Posted: Wed Jan 02, 2019 5:19 pm
by 15685014
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:
- Dashes is printed two times thicker than should be (it is like left axis line, but should be like top and right wall line)
- 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).
Re: Chart printing questions
Posted: Fri Jan 04, 2019 12:34 pm
by Marc
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
Re: Chart printing questions
Posted: Wed Jan 09, 2019 7:36 am
by 15685014
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).
Re: Chart printing questions
Posted: Fri Jul 19, 2019 9:50 am
by 15685014
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.