There seems to be an issue with exporting area charts with transparencies to PDF. Here is what my chart looks like on screen:
And here is what it looks like in the resulting PDF:
Here is my export code:
section.PageSize =
new PageSize(Converter.MillimetersToPoints(210), Converter.MillimetersToPoints(297));
section.PageOrientation =
PageOrientation.Landscape;
chart.RenderPdfFriendlyGraphics(graphics, chart.Width, (
int)Math.Round(chart.Width * (210.0 / 297.0)));
report.Publish(path,
FileFormat.PDF);
And the PaintElement I am adding to the NumericTimeSeries (This is a composite chart - layer type AreaChart)
var paintElement = new PaintElement();
paintElement.ElementType =
PaintElementType.Gradient;
paintElement.FillGradientStyle =
GradientStyle.Vertical;
paintElement.FillStopOpacity = 0;
paintElement.FillOpacity = 167;
This is a bug - Each series is rendered opaque in the resulting PDF.
Closest thing to a workaround is adding series to the chart in order of peak value.
Bug is still present in service release 2119
using System; using System.Drawing; using System.Windows.Forms; using Infragistics.Documents.Report; using Infragistics.Documents.Utils; using Infragistics.UltraChart.Resources.Appearance; using Infragistics.UltraChart.Shared.Styles; using Infragistics.Win.UltraWinChart; namespace UltraChartPdfExport { public static class Program { [STAThread] public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (var form = new TestForm()) { Application.Run(form); } } } public class TestForm : Form { private readonly UltraChart chart = new UltraChart(); private static readonly Random rand = new Random(); public TestForm() { chart.ChartType = ChartType.Composite; chart.Border.Thickness = 0; chart.Dock = DockStyle.Fill; var axisX = new AxisItem(); axisX.OrientationType = AxisNumber.X_Axis; axisX.DataType = AxisDataType.Time; axisX.Extent = 0; axisX.LineThickness = 0; var axisY = new AxisItem(); axisY.OrientationType = AxisNumber.Y_Axis; axisY.Extent = 0; axisY.LineThickness = 0; var area = new ChartArea(); area.Axes.Add(axisX); area.Axes.Add(axisY); area.Border.Thickness = 0; var layer = new ChartLayerAppearance(); layer.ChartType = ChartType.AreaChart; layer.ChartArea = area; layer.AxisX = axisX; layer.AxisY = axisY; chart.CompositeChart.ChartAreas.Add(area); chart.CompositeChart.ChartLayers.Add(layer); layer.Series.Add(GetSeries(Color.Red, "Series A")); layer.Series.Add(GetSeries(Color.Green, "Series B")); layer.Series.Add(GetSeries(Color.Blue, "Series C")); Controls.Add(chart); Load += TestForm_Load; } private NumericTimeSeries GetSeries(Color color, string key) { var paintElement = new PaintElement(); paintElement.ElementType = PaintElementType.Gradient; paintElement.FillGradientStyle = GradientStyle.Vertical; paintElement.FillStopOpacity = 0; paintElement.FillOpacity = 167; paintElement.Fill = color; paintElement.Stroke = color; var series = new NumericTimeSeries(); for (var date = DateTime.Today.AddDays(-1); date < DateTime.Today; date = date.AddMinutes(30)) { series.Points.Add(new NumericTimeDataPoint(date, rand.NextDouble(), null, false)); } series.Points.Add(new NumericTimeDataPoint(DateTime.Today, rand.NextDouble(), null, false)); series.Key = key; series.Label = key; series.PEs.Add(paintElement); return series; } private void TestForm_Load(object sender, EventArgs e) { var report = new Report(); var section = report.AddSection(); section.PageSize = new PageSize(Converter.MillimetersToPoints(210), Converter.MillimetersToPoints(297)); section.PageOrientation = PageOrientation.Landscape; var marginX = Converter.MillimetersToPoints(297) * 0.04f; var marginY = Converter.MillimetersToPoints(210) * 0.04f; section.PageMargins = new Infragistics.Documents.Report.Margins(marginX, marginY, marginX, marginY); using (var graphics = section.AddCanvas().CreateGraphics()) { chart.RenderPdfFriendlyGraphics(graphics, (int)Math.Round(Converter.MillimetersToPoints(297) * 0.92f), (int)Math.Round(Converter.MillimetersToPoints(210) * 0.92f)); using (var form = new SaveFileDialog()) { form.Filter = "PDF Files | *.pdf"; if (form.ShowDialog(this) == DialogResult.OK) { report.Publish(form.FileName, FileFormat.PDF); } } } } } }