Hi,
I created an ultrawinchart and I want to make a report within the ultrawinchart. For this I used the RenderPdfFriendlyGraphics function. With this function the rendering of the diagram works well but the legend is outside the diagramm. I think the rendering function don't work at the legend. Here is my code snippet:
Infragistics.Documents.Report.ICanvas canvas = page.AddCanvas(0, 0); Graphics g = canvas.CreateGraphics(); ultraChart.RenderPdfFriendlyGraphics(g, 200, 200);
If I don't use the scale function (third line) the legend is shown at the right position, but the chart is to large to show it on an A4-paper. Does somebody has an idea.
the legend showed up inside the chart when I tried the same thing. could you post a screenshot of what you're seeing, and also let us know the (4-part) version number of the dll you are using?
during making the requested screenshots (I post you the pdf-documents). I find out the following:
If I use the function ultraChart.RenderPdfFriendlyGraphics(g) with only one parameter the legend is shown at the expected position. If I use this method with three parameters (ultraChart.RenderPdfFriendlyGraphics(g, 400, 200)) the chart is shown as expected, but the legend is displayed at old position (with only one parameter). I use the function with three paremeter to scale down the graphic with the result that the legend is show outside the chart (see attachments).
no, that version should be working. i tested this code with those dlls and the legend printed in the correct position. am i missing something?
private void Form1_Load(object sender, EventArgs e) { this.ultraChart1.ChartType = ChartType.Composite; this.ultraChart1.CompositeChart.ChartAreas.Add(new ChartArea()); this.ultraChart1.CompositeChart.ChartAreas[0].Axes.Add(new AxisItem() { OrientationType = AxisNumber.X_Axis, DataType = AxisDataType.String, SetLabelAxisType = SetLabelAxisType.ContinuousData, Key = "xAxis" }); this.ultraChart1.CompositeChart.ChartAreas[0].Axes.Add(new AxisItem() { OrientationType = AxisNumber.Y_Axis, DataType = AxisDataType.Numeric, Key = "yAxis" }); this.ultraChart1.CompositeChart.ChartLayers.Add(new ChartLayerAppearance() { ChartType = ChartType.LineChart, ChartArea = this.ultraChart1.CompositeChart.ChartAreas[0], AxisX = this.ultraChart1.CompositeChart.ChartAreas[0].Axes.FromKey("xAxis"), AxisY = this.ultraChart1.CompositeChart.ChartAreas[0].Axes.FromKey("yAxis"), }); NumericTimeSeries series1 = new NumericTimeSeries() { Label = "Series A" }; series1.Points.Add(new NumericTimeDataPoint(DateTime.Now.AddDays(0.0), 1.0, "a", false)); series1.Points.Add(new NumericTimeDataPoint(DateTime.Now.AddDays(1.0), 2.0, "b", false)); series1.Points.Add(new NumericTimeDataPoint(DateTime.Now.AddDays(2.0), 3.0, "c", false)); this.ultraChart1.CompositeChart.ChartLayers[0].Series.Add(series1); this.ultraChart1.CompositeChart.Legends.Add(new CompositeLegend() { Bounds = new Rectangle(0, 90, 30, 10), BoundsMeasureType = MeasureType.Percentage, }); this.ultraChart1.CompositeChart.Legends[0].Border.CornerRadius = 25; this.ultraChart1.CompositeChart.Legends[0].ChartLayers.Add(this.ultraChart1.CompositeChart.ChartLayers[0]); this.Size = this.ultraChart1.Size = new Size(1000, 1000); Report report = new Report(); ISectionPage page = report.AddSection().AddPage(); ICanvas canvas = page.AddCanvas(0, 0); Graphics g = canvas.CreateGraphics(); this.ultraChart1.RenderPdfFriendlyGraphics(g, 200, 200); report.Publish(@"C:\report.pdf", FileFormat.PDF); }
ah, maybe the problem is your Legend is positioned with BoundsMeasureType.Pixels, and that causes the discrepancy with the legend position...? if so, then that is the expected behavior and you need to change your legend position before exporting to PDF.
I didn't exactly understand what do you mean. I set the legend position with legend.Bounds = newRectangle(...). If the application window size is changed or the size of the ultrachart inside the application window the legend position inside the ultrachart window is changed too. So I have to do it like described above.
Do you mean that I have to change the position of the legend like I did it before when the ultrachart size was changed?
or you could set Legend.BoundsMeasureType = Percent and use percent values to ensure the legend is always in the same place.
OK, thank you, it works!