Hi,
I am using scatter chart, and I am currently plotting for multiple days on which I modify x-axis with IRenderLabel to display time instead of numerica values.
Then, if I am plotting for 3 days, is there a way I can change the chart area's Background color such as distinct color for each day?
Day 1 = Red; Day 2 = Blue; etc.
Or if the above is not possible, change the line color per day change? (red for day 1, and then the line color changes to blue when it goes for day2, etc.)
zakia,
this is just a matter of finding the right index at which to insert the Boxes. you can see in the last code sample i posted how the "primitivePositions" dictionary is used to store the index for each Box i add to the SceneGraph.
I have a question about: Add colored Boxes to the SceneGraph behind the scatter datapoints...
I succed to add colored boxes to the SceneGraph, but I don't find how to put them behind the datapoints.
Thankx
modified the fillscenegraph code to prevent this. note how a dictionary is used to store the index at which to insert primitives later
Private Sub UltraChart1_FillSceneGraph(ByVal sender As Object, ByVal e As Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph Dim xAxis As IAdvanceAxis = CType(e.Grid("X"), IAdvanceAxis) Dim yAxis As IAdvanceAxis = CType(e.Grid("Y"), IAdvanceAxis) If xAxis Is Nothing OrElse yAxis Is Nothing Then Return Dim clipper As New GraphicsContext() clipper.SetClipBounds(New Rectangle(xAxis.MapMinimum, yAxis.MapMaximum, xAxis.MapRange, yAxis.MapRange)) e.SceneGraph.Add(clipper) Dim bottom As Integer = Convert.ToInt32(yAxis.MapMinimum) Dim primitivesToAdd As New PrimitiveCollection() Dim primitivePositions As New Dictionary(Of Primitive, Integer) For Each p As Primitive In e.SceneGraph If TypeOf p Is Polyline Then Dim dataLine As Polyline = CType(p, Polyline) Dim newPoints As New List(Of DataPoint)(dataLine.points) Dim firstPoint As DataPoint = newPoints(0) Dim lastPoint As DataPoint = newPoints(newPoints.Count - 1) newPoints.Add(New DataPoint(lastPoint.point.X, bottom)) newPoints.Add(New DataPoint(firstPoint.point.X, bottom)) newPoints.Add(New DataPoint(firstPoint.point)) Dim oly As New Polygon(newPoints.ToArray()) oly.PE = dataLine.PE oly.splineTension = dataLine.splineTension oly.flatBottom = True primitivesToAdd.Add(oly) primitivePositions.Add(oly, e.SceneGraph.IndexOf(p) + 1) End If Next For Each p As Primitive In primitivesToAdd e.SceneGraph.Insert(primitivePositions(p), p) Next End Sub
Thanks David. I have another questions. It seems that adding this polygons on the FillSceneGraph event impacts the appearance of everything else such as annotations or ChartTextApperance. I used these codes below to display my data values, but they are covered by the green polygon. Any advice? Image is attached. Thanks again. Bobby Pohan
' prepare the display elevation values functionality
ScatterChartAppearance
ChartTextAppearance
chartTextAppearance.ChartTextFont =
, 8.0!)
chartTextAppearance.Column = -2
chartTextAppearance.Row = -2
chartTextAppearance.ItemFormatString =
"<DATA_VALUE_Y:00.000>"
scatterChartAppearance.ChartText.Add(chartTextAppearance)
.NLDChart.ScatterChart = scatterChartAppearance
you can use a GraphicsContext primitive to set the clip bounds so this doesn't happen.
Private Sub UltraChart1_FillSceneGraph(ByVal sender As Object, ByVal e As Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph Dim xAxis As IAdvanceAxis = CType(e.Grid("X"), IAdvanceAxis) Dim yAxis As IAdvanceAxis = CType(e.Grid("Y"), IAdvanceAxis) If xAxis Is Nothing OrElse yAxis Is Nothing Then Return Dim clipper As New GraphicsContext() clipper.SetClipBounds(New Rectangle(xAxis.MapMinimum, yAxis.MapMaximum, xAxis.MapRange, yAxis.MapRange)) e.SceneGraph.Add(clipper) Dim bottom As Integer = Convert.ToInt32(yAxis.MapMinimum) Dim primitivesToAdd As New PrimitiveCollection() For Each p As Primitive In e.SceneGraph If TypeOf p Is Polyline Then Dim dataLine As Polyline = CType(p, Polyline) Dim newPoints As New List(Of DataPoint)(dataLine.points) Dim firstPoint As DataPoint = newPoints(0) Dim lastPoint As DataPoint = newPoints(newPoints.Count - 1) newPoints.Add(New DataPoint(lastPoint.point.X, bottom)) newPoints.Add(New DataPoint(firstPoint.point.X, bottom)) newPoints.Add(New DataPoint(firstPoint.point)) Dim oly As New Polygon(newPoints.ToArray()) oly.PE = dataLine.PE oly.splineTension = dataLine.splineTension oly.flatBottom = True primitivesToAdd.Add(oly) End If Next e.SceneGraph.AddRange(primitivesToAdd.ToArray()) End Sub