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'm glad it works perfectly. 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
End If
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)
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.
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.
I will try your code and get back to you.