Page 1 of 1

Qprintinng Chart labels on printing page

Posted: Fri Mar 14, 2014 7:44 am
by 15666633
Hello, i have a question, when i print chart using TeeChart print preview dialog i can see, text quality is high, but the size of it is very small, so it looks like that for printing this chart TeeChart use to scale the specified size of chart to some special value, and after that print the big image to smaller area of print document, Is my assumption correct? if yes, couldn't you tell the optional proportion of the chart to get the same quality of text on printing chart, because i use this approach to draw my own print document with chart bitmap. Here you can see my code

Code: Select all

private void OnPrint(object sender, PrintPageEventArgs ev)
    {
      Size chartOriginSize = m_TChart.Size;
      Color panelColor = m_TChart.Chart.Panel.Color;
      Color BackColor = m_TChart.Walls.Back.Color = Color.White; ;

      m_TChart.AutoRepaint = false;

      SetChartPrintProps(ev);

      Font printFont = new Font("Arial", 15);
      SizeF TitleSize = ev.Graphics.MeasureString(m_PrintName, printFont);
     

      ev.Graphics.DrawImage(m_TChart.Bitmap, ev.MarginBounds.X, ev.MarginBounds.Y + TitleSize.Height + 10 + 11 * printFont.GetHeight(), ev.MarginBounds.Width, 400);
      }

      RestoreChartProps(ref chartOriginSize, ref panelColor, ref BackColor);

      m_TChart.AutoRepaint = true;
    }

    private void SetChartPrintProps(PrintPageEventArgs ev)
    {
      m_TChart.Dock = DockStyle.None;
      double width = ev.MarginBounds.Width * 1.5;// a bit of magic
      double height = 400 * 1.5 ; 
      m_TChart.Size = new Size((int)width, (int)height);
      m_TChart.Chart.Panel.Color = Color.White;
      m_TChart.Chart.Panel.Gradient.Visible = false;
      m_TChart.Walls.Back.Gradient.Visible = false;
      m_TChart.BackColor = Color.White;
      m_TChart.Panel.BorderRound = 1;
    }
but i can't say that i'm complitely satisfied with the result, so i nedd the proper proportions.
In other Case( probably preferable ), how can use standart TeeChart printing facilities, to move the chart drawing place for example to the top of a document, and to make all the background white( all the actions are made in my SetChartPrintProps function, except sizing ). Thanks.

Re: Qprintinng Chart labels on printing page

Posted: Fri Mar 14, 2014 10:54 am
by Christopher
Petr wrote: In other Case( probably preferable ), how can use standart TeeChart printing facilities, to move the chart drawing place for example to the top of a document, and to make all the background white( all the actions are made in my SetChartPrintProps function, except sizing ). Thanks.
Have you seen "Tutorial14 - Printing Charts" in the file under:
%Program Files%\Steema Software\Steema TeeChart for .NET 2014 4.1.2014.02240\Docs\TeeChart for .Net Tutorials.chm ?

You could try something like this:

Code: Select all

   private void button1_Click(object sender, EventArgs e)
    {
      SetChartPrintProps();
      m_TChart.Printer.BeginPrint();
      m_TChart.Printer.Print(new Rectangle(100, 10, 300, 200));
      m_TChart.Printer.Preview();
      RestoreChartProps();
    }

    MemoryStream ms = new MemoryStream();
    private void RestoreChartProps()
    {
      ms.Position = 0;
      m_TChart.Import.Template.Load(ms);
    }

    private void SetChartPrintProps()
    {
      ms.Position = 0;
      m_TChart.Export.Template.Save(ms);

      m_TChart.Chart.Panel.Gradient.Visible = false;
      m_TChart.Chart.Panel.Color = Color.White;


      m_TChart.Walls.Back.Gradient.Visible = false;
      m_TChart.Walls.Back.Color = Color.White;

      m_TChart.Panel.BorderRound = 1;

      m_TChart.Axes.Left.Grid.Visible = false;
      m_TChart.Axes.Bottom.Grid.Visible = false;
    }