Jump to content
Software FX Community

johnt

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by johnt

  1. I'm evaluating ChartFX for WPF for an application that generates reports. We are trying to create report pages in XAML and then export them to XPS documents. It has worked very well except we've had trouble getting charts to work right (not just ChartFX...). When the charts are written to the XPS document, only the borders/background of the chart appear. The main pane, axes, series, etc. do not show. I saw a similar problem that happened when printing charts that were not visually displayed so it may be related. Here is some sample code that reproduces this. I place the chart control in a FixedDocument and then write that document using XpsDocumentWriter.Write(Visual visual). The chart appears fine when the document is displayed in a document viewer, but it is not correct in the XPS file which leads me to believe its only an issue when "drawing" the chart in the XpsDocumentWriter. Size pageSize = new Size(96 * 8.5, 96 * 11); // create the fixed pageFixedPage fixedPage = new FixedPage();fixedPage.Background = Brushes.White; fixedPage.Width = pageSize.Width; fixedPage.Height = pageSize.Height; // add the chart controlChart chart = new Chart(); chart.Background = new SolidColorBrush(Colors.Green);FixedPage.SetLeft(chart, 96 * 0.75);FixedPage.SetTop(chart, 96 * 0.75); chart.Width = 300; chart.Height = 300; fixedPage.Children.Add((UIElement)chart); // update sizesfixedPage.Measure(pageSize); fixedPage.Arrange(new Rect(new Point(), pageSize)); fixedPage.UpdateLayout(); // create the documentFixedDocument document = new FixedDocument(); document.DocumentPaginator.PageSize = pageSize; PageContent pageContent = new PageContent();((IAddChild)pageContent).AddChild(fixedPage); document.Pages.Add(pageContent); // save as xpsstring fileName = "chart.xps"; Package package = Package.Open(fileName, FileMode.Create);XpsDocument xpsDocument = new XpsDocument(package);XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument); xpsWriter.Write(document); package.Flush(); package.Close();
×
×
  • Create New...