Page 1 of 1

How to print child chart for TeeChart.WPF

Posted: Thu Jun 26, 2014 3:25 am
by 15656007
I create more child chart in tChart1, but how to print child chart, please look at the code:

// init child chart
for (int i = 0; i < 4; i++) {
Steema.TeeChart.WPF.TChart child = new Steema.TeeChart.WPF.TChart();
...
...
tChart1.Children.Add(child);
}

// Referring to the teechart wpf example
documentViewer1.Document = CreateFixedDocumentWithPage();

// Referring to the teechart wpf example
FixedDocument CreateFixedDocument() { ... }
...

private PageContent CreateFirstPageContent() {
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
Canvas canvas1 = new Canvas();

...
Steema.TeeChart.WPF.TChart child = (Steema.TeeChart.WPF.TChart)tChart1.Children[0];
DrawingVisual d = new DrawingVisual();
DrawingContext g = d.RenderOpen();
child.Draw(g);
AdornerLayer parent = AdornerLayer.GetAdornerLayer(child);
if (parent != null)
{
Adorner[] adorners = parent.GetAdorners(child);
if (adorners != null)
{
foreach (TeeAdorner item in adorners)
{
item.Draw(g);
}
}
}
g.Close();
...

fixedPage.Children.Add(canvas1);

....
}

-----------------------------------------------------------------------------------------------------------------------------

why child chart can not print in DocumentViewer? Please taught me how to do, thanks.

I'm working environment is: VS2010(.NET Framework 4.0) / Windows7

Re: How to print child chart for TeeChart.WPF

Posted: Thu Jun 26, 2014 10:28 am
by narcis
Hi Candy,

You should do something very similar to the demo. Find attached a simple example project showing it. This is a Visual Studio 2013 .NET Framework 4.5.1 project. You just need to change the project TeeChart.WPF.dll reference to the version you use. If you have any problem with the project just use MainWindow.xaml and MainWindow.xaml.cs.

Re: How to print child chart for TeeChart.WPF

Posted: Fri Jun 27, 2014 6:23 am
by 15656007
I was successful, thank you very much :D