Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
266
Smart ScatterChart Labels
posted

I have a scatter chart (pictured below), you can see that the labels overlap. Which isnt so good. Im looking for a way to make these labels display nicely together. Maybe callout style box with a line connecting to the point its associated with.

I couldnt find a way to offset the standard labels so these you can see here are done by adding text to a new layer at each of the points (with an offset). Based on an example i found somewhere on the infragistics help site ....
 

public class CustomSplatterChartPointLabel : ILayer

{

    public void FillSceneGraph(SceneGraph scene)

    {

        // Find all the point Primitives

        ArrayList pointSets = new ArrayList();

        foreach (Primitive p in scene)
        {
            PointSet ps = p as PointSet;

            if (ps != null)
            {
                pointSets.Add(ps);
            }
        }

        // Reset so we can draw anywhere on the chart

        GraphicsContext gc = new GraphicsContext();
        gc.ResetClip();
        scene.Add(gc);

        // Loop through points and add custom labels

        foreach (PointSet ps in pointSets)

        {

            Point p = ps.points[0].point;
            int xpos = p.X + 15;
            int ypos = p.Y;

            Text myText = new Text(new Point(xpos, ypos), ps.Series.Label,
            new LabelStyle());

            myText.labelStyle.Font = new Font(myText.labelStyle.Font.FontFamily, 11,
                FontStyle.Regular, GraphicsUnit.Pixel);

            myText.labelStyle.FontColor = Color.Black;

            scene.Add(myText);

        }

    }

    [ ... Standard ILayer Implementation ... ]

}

 

Id like to know if there's a straight forward way of doign this? is there something built in that i can use that i may have overlooked rather than going ahead with some custom layer stuff ?

 

Right now im thinking of figuring out where the point is in relation to the edges (quadrant) and then offsetting the label accordingly. But im not sure that will full solve the issue since it seems like many of the points will be landing ontop of each other. A more complicated solution would be to plot the labels further away from their points but connect a line back to the point. 

 

Any Ideas? thoughts? suggestion? solutions? 

Thanks, Jeffrey 

Parents
No Data
Reply
  • 28496
    Offline posted

     You can achieve something similar by adding CalloutAnnotation(s) to the Annotations collection.  However, I would stick with the layer as it is a more flexible solution.  Using the Callout primitive to surround your text might be a good option.

Children
No Data