On many of the charts, the legend will show a colored box that represents a 'line' on the chart. Can the colored box be changed to a line (for the Legend)?
this is the default behavior if the Series collection is used for data (instead of the DataSource property) and the chart type is LineChart. if not, you can use the FillSceneGraph event to find the legend boxes and replace them with lines.
Thanks Vince!
I used the FillSceneGraph event and it worked. Here is what I did if it helps someone...
Dim
primitivesToAdd As New PrimitiveCollection()
Then
newLegendLine.PE = p.PE
newLegendLine.PE.StrokeWidth = 3
primitivesToRemove.Add(BoxLegendIcon)
primitivesToAdd.Add(newLegendLine)
Next
e.SceneGraph.Remove(p)
e.SceneGraph.AddRange(primitivesToAdd.ToArray())
Hi,
Could anyone help me in replacing this code in C#?
Appreciate your help.
PrimitiveCollection primitivesToAdd = new PrimitiveCollection();
PrimitiveCollection primitivesToRemove = new PrimitiveCollection();
foreach (Primitive p in e.SceneGraph)
{
if (p is Box && !string.IsNullOrEmpty(p.Path) && p.Path.Contains("Legend")))
Box boxLegendIcon = (Box)p;
Point startPoint = boxLegendIcon.rect.Location;
int width = boxLegendIcon.rect.Right;
Point endPoint = new Point(startPoint.X + width, startPoint.Y);
DataPoint[] ptArray = new DataPoint[]
new DataPoint(startPoint),
new DataPoint(endPoint)
};
Polyline newLegendLine = new Polyline(ptArray);
newLegendLine.PE = p.PE;
newLegendLine.PE.StrokeWidth = 3;
primitivesToRemove.Add(boxLegendIcon);
primitivesToAdd.Add(newLegendLine);
}
foreach (Primitive p in primitivesToRemove)
e.SceneGraph.Remove(p);
e.SceneGraph.AddRange(primitivesToAdd.ToArray());
Thanks David,
It really helped to complete my task.