When trying to print the chart out using the ultrachart's PrintDocument property, custom annotations appear in the wrong location and modifications made during the FillSceneGraph and ChartDrawItem events do not appear as part of the print document. Is there any way to solve this problem?
Report r = new Report(); ISection sec = r.AddSection(); sec.PageOrientation = PageOrientation.Landscape; this.ultraChart1.RenderPdfFriendlyGraphics(sec.AddCanvas().CreateGraphics()); r.Publish("C:\\blah.pdf", FileFormat.PDF);
I am using version 8.2.20082.1000 of the chart. One difference is that I am using a Location.Type of Pixels. I am creating the Annotations when the user clicks on a DataElement and I am offsetting it by using BoxAnnotation.GetRenderPointFromParent()
I can get the labels to appear correctly if I use the example above and use the chart as an image. The output doesn't look as nice, but it works.
I also experimented with saving to a PDF by using chart.RenderPdfFriendlyGraphics(r.AddSection().AddCanvas().CreateGraphics()). This works and the output in the PDF looks good with the labels in the correct place as long as I don't send in a width or height to the above call. My charts are wide and get chopped off in the PDF. Is there a way to specify that the page in the PDF is landscape when the chart is written? If I open the PDF and change the setup to landscape, it is too late since the chart was already rendered to the PDF.
jcaplantrp:
private void Form1_Load(object sender, EventArgs e) { this.ultraChart1.Data.DataSource = Infragistics.UltraChart.Data.DemoTable.Table(); this.ultraChart1.Data.DataBind(); BoxAnnotation boxAnno = new BoxAnnotation(); boxAnno.PE = new PaintElement(Color.PaleGreen); boxAnno.Text = "hello"; boxAnno.Location.Type = LocationType.RowColumn; boxAnno.Location.Row = boxAnno.Location.Column = -2; this.ultraChart1.Annotations.Add(boxAnno); PrintDocument myPrintDoc = new PrintDocument(); myPrintDoc.PrintPage += new PrintPageEventHandler(myPrintDoc_PrintPage); myPrintDoc.Print(); } void myPrintDoc_PrintPage(object sender, PrintPageEventArgs e) { Image chartImage = this.ultraChart1.Image; e.Graphics.DrawImage(chartImage, Point.Empty); e.HasMorePages = false; }
this code worked for me without any problems using version 8.3.20083.1009. what version of the dll are you using? does this code work for you?
private void Form1_Load(object sender, EventArgs e) { this.ultraChart1.Data.DataSource = Infragistics.UltraChart.Data.DemoTable.Table(); this.ultraChart1.Data.DataBind(); BoxAnnotation boxAnno = new BoxAnnotation(); boxAnno.PE = new PaintElement(Color.PaleGreen); boxAnno.Text = "hello"; boxAnno.Location.Type = LocationType.RowColumn; boxAnno.Location.Row = boxAnno.Location.Column = -2; this.ultraChart1.Annotations.Add(boxAnno); PrintDocument doc = this.ultraChart1.PrintDocument; doc.Print(); //this.ultraChart1.PrintChart(); }
I know it will potentially change the locations of things set by pixel location (which makes sense) or percentage location (which makes no sense, whether the object is 10 pixes or 10000 pixels in size, 1 percent is still 1 percent).
However, I located my annotations by row/column location. Again, just as with percentage, a row is a row, and a column is a column, and the locations of the annotations should appear over the row and column where they have been located regardless of whether the size of the chart changes to fit the page. If these things are not working correctly, in my opinion, there is a bug in the software.
Have you actually tested this out, is there a fix coming anytime in the forseeable future? Everything else appears to be resized and relocated correctly, I am not sure why it is that custom annotations can not be handled in this way as well.