I have seen this use crop up from time to time. Here is my "AS IS" code I hope it may help someone else Dim p As Primitive Dim primitivesToAdd As PrimitiveCollection = New PrimitiveCollection() Dim primitivesToRemove As PrimitiveCollection = New PrimitiveCollection()
Dim xAxis As IAdvanceAxis = Nothing Dim yAxis As IAdvanceAxis = Nothing
If uchartPersonChart.CompositeChart.ChartLayers.Count > 0 Then xAxis = CType(uchartPersonChart.CompositeChart.ChartLayers(0).ChartLayer.Grid("X"), IAdvanceAxis) yAxis = CType(uchartPersonChart.CompositeChart.ChartLayers(0).ChartLayer.Grid("Y"), IAdvanceAxis) If xAxis Is Nothing Or yAxis Is Nothing Then Return End If End If
Dim olayers As ChartLayerCollection = uchartPersonChart.CompositeChart.ChartLayers Dim icurrentLayerIndex As Integer = 0 Dim currentLayer As ChartLayerAppearance = olayers(icurrentLayerIndex)
For Each p In e.SceneGraph If uchartPersonChart.CompositeChart.Legends.Count > 0 Then If uchartPersonChart.CompositeChart.Legends(0).ChartLayers.Count > 0 Then Dim lineApp As LineChartAppearance = CType(currentLayer.ChartTypeAppearance, LineChartAppearance) Dim seriesCounter As Integer = 0 If Not IsNothing(p.Path) Then If UCase(p.Path) = "LEGEND" Then Dim oPoly As Polyline = CType(p, Polyline) If (TypeOf p Is Polyline) Then oPoly = CType(p, Polyline) If Not oPoly Is Nothing Then ' we found a polyline in the legend. let's replace it. ' get the centerpoint of the polyline ' get the correct icon Dim sym As Symbol = New Symbol() ' get the centerpoint of the polyline sym.point = New Point((oPoly.points(0).point.X + oPoly.points(oPoly.points.Length - 1).point.X) / 2, (oPoly.points(0).point.Y + oPoly.points(oPoly.points.Length - 1).point.Y) / 2) ' get the correct icon sym.icon = lineApp.LineAppearances(oPoly.Row).IconAppearance.Icon oPoly.PE.StrokeWidth = CInt(2.5) sym.PE = oPoly.PE primitivesToAdd.Add(sym) primitivesToRemove.Add(oPoly) End If seriesCounter = seriesCounter + 1 If (seriesCounter >= currentLayer.Series.Count And olayers.Count > icurrentLayerIndex + 1) Then icurrentLayerIndex = icurrentLayerIndex + 1 currentLayer = olayers(icurrentLayerIndex) If currentLayer.ChartType <> ChartType.GanttChart Then lineApp = CType(currentLayer.ChartTypeAppearance, LineChartAppearance) seriesCounter = 0 End If End If End If End If End If End If End If Next p e.SceneGraph.AddRange(primitivesToAdd.ToArray()) For Each p In primitivesToRemove e.SceneGraph.Remove(p) Next
Here is the sample
Hi,
Maybe another possible approach could be if you are using ScatterLineChart. More details you could find in attached sample.
Let me know if you have any questions.