Hi,
I want to have segments of a polyline in a ScatterGraph appear as different colours.
How can I control the colour of a line segment between two data points to be a specific (data controled) color?
thanksl
you could change it to a Polyline, which does have a splineTension field. however, with only 2 points, spline tension will have no effect.
possibly the only solution for this is to use a Path primitive and draw the curve as a bezier spline inside the GraphicsPath object. calculating the control points for the bezier spline is a very tricky problem, though.
you could also try adding a GraphicsContext to the scene before the Polyline, using the GraphicsContext to set the clip bounds beforehand, so that only the space between the two points is visible.
Hi David,
I am using a scatter plot where I set the ScatterChart.ConnectWithLines = True. Then I implemented your code above to "highlight" a segment of the graph. I write the code on VB.net. However, it seems the line is not as smooth as the graph's lines. There is no splinetension property on Line class. Do you have any suggestion to smooth this line? Thanks.Bobby Pohan
here's some code to give you an idea of what to do
private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e) { PrimitiveCollection primitivesToAdd = new PrimitiveCollection(); foreach (Primitive p in e.SceneGraph) { PointSet pS = p as PointSet; if (pS != null) { for (int i = 0; i < pS.points.Length - 1; i++) { Line lineToAdd = new Line(pS.points[i].point, pS.points[i + 1].point); if (i % 2 == 0) { lineToAdd.PE.Stroke = Color.Pink; } else { lineToAdd.PE.Stroke = Color.Lime; } primitivesToAdd.Add(lineToAdd); } } } e.SceneGraph.AddRange(primitivesToAdd.ToArray()); }
I see the SceneGraph object, but dont see any member that gets me to a set of PointSet objects. Am i following correctly?
Do I add Lines or modify the existing Lines?
thx
this behavior is not available as a feature of the chart, but you can achieve it using FillSceneGraph.
handle the chart's FillSceneGraph event, loop through e.SceneGraph, find the PointSet that represents all your scatter points, and add Line primitives to the SceneGraph, each of which has a different color.