I use FillSceneGraph to display a number of types on the graph. For example if a Y axis value is below some limit i draw a Ellipse around the symbol. I also draw lines and text with no issue EXCEPT for a single Text object that i draw at the bottom left corner of the graph that contains the date and time the graph was generated.
All good so far.
When i print the graph all objects display and print in the correct position EXCEPT this Text ofject that ends up being drawn in the middle of the graph.
code:
targetLabel = New Infragistics.UltraChart.Core.Primitives.Text()
targetLabel.SetTextString(labelText)
targetLabelSize = Size.Ceiling(Infragistics.UltraChart.Core.Util.Platform.GetLabelSizePixels(targetLabel.GetTextString(), targetLabel.labelStyle))
targetLabel.bounds = New Rectangle(5, UltraChart1.Height - targetLabelSize.Height - 5, targetLabelSize.Width, targetLabelSize.Height)
e.SceneGraph.Add(targetLabel)
Pat,
I would like to try to reproduce this. What chart style is your graph?
Have you been able to straighten this out?
If you are talking about a standard .NET Label control, that would work only it won't print using
Private Sub tpPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tpPrintPreview.Click
Me.UltraPrintPreviewDialog1.Document = Me.UltraChart1.PrintDocument
If Me.UltraPrintPreviewDialog1.ShowDialog() = DialogResult.OK Then
Me.UltraPrintPreviewDialog1.Document.Print()
End If
End Sub
--------------------------------------------------------
Did you try your code above with the Print Preview or just Print. In my case the Text Primitive gets moved.
i am basically do whay you show about only in VB. See code below.
Within the FillSceneGraph event handler i have:
End
I will try your code and get back to you.
OK, I tried it with the PrintPreviewDialog and I see what you mean. I will show this to my developer and get back to you early in the week.
The PrintPreview changes the size of the Chart o fit the page so we have to get the Chart's true bounds inside FillSceneGraph. Try this code inside the FillSceneGraph event instead of the code I gave you before:
Size chartSize = chart.Size;
TitleLayer titleLayer = args.ChartCore.GetTitleLayer();
if (!titleLayer.OuterBound.IsEmpty)
{
chartSize = titleLayer.OuterBound.Size;
}
Text label = new Text();
label.SetTextString("Date with text");
Size labelSize = Size.Ceiling(Platform.GetLabelSizePixels(label.GetTextString(), label.labelStyle));
label.bounds = new Rectangle(5, chartSize.Height - labelSize.Height - 5, labelSize.Width, labelSize.Height);
args.SceneGraph.Add(label);
I am attaching here a sample application which uses this code so you can see it in action. Let me know if you have further questions.
Thanks! Works perfectly.
Here is my VB.net version
Dim chartSize As Size
chartSize = UltraChart1.Size
Dim titleLayer As TitleLayer
titleLayer = e.ChartCore.GetTitleLayer()
If Not titleLayer.OuterBound.IsEmpty() Then
chartSize = titleLayer.OuterBound.Size
Dim targetLabel As Infragistics.UltraChart.Core.Primitives.Text
Dim targetLabelSize As Size
targetLabelSize = Size.Ceiling(Infragistics.UltraChart.Core.Util.Platform.GetLabelSizePixels(targetLabel.GetTextString(),targetLabel.labelStyle))
targetLabel.bounds = New Rectangle(5, chartSize.Height - targetLabelSize.Height - 5, targetLabelSize.Width, targetLabelSize.Height)
I'm glad it works perfectly. Let me know if you have further questions.