C1Flexchart: Select scatter point in a rectangle?

Posted by: hdle on 30 September 2026, 11:54 pm EST

  • Posted 30 September 2026, 11:54 pm EST - Updated 30 September 2026, 11:59 pm EST

    Hi,

    I have a scatter plot where the users need to select one or more point in a user selected rectangle. Is that possible?

    Basically, the user click on the plot, drag to create the rectangle, and all point in the rectangle is selected. By selected, it can mean the point changes to a selected color.

    Thanks,

    Hai

  • Posted 1 October 2026, 6:37 am EST

    Hi Hai,

    Yes, this is possible with FlexChart. I have attached a sample (FlexChart_Sample.zip) that does exactly what you describe: the user drags a rectangle on the plot, and all points inside it change to a selected color.

    The approach has four parts:

    1. Handle MouseDown, MouseMove and MouseUp on the chart to track the start and end pixel positions of the rectangle. Clamp the end point to chart.PlotRect so the rectangle stays inside the plot area.
    2. Draw the dashed rectangle in the Rendered event using e.Engine.DrawRect, and call chart.Refresh() from MouseMove so it follows the mouse.
    3. On MouseUp, convert both corners to data coordinates with chart.PointToData(), then loop over the series values (series.GetValues(0) for Y, series.GetValues(1) for X) and store the indices of the points that fall inside the rectangle.
    4. Handle the series SymbolRendering event and call e.Engine.SetFill(…) with the selected color when e.Index is in the stored set. Refresh the chart after MouseUp to repaint.

    After MouseUp, the stored indices (SelectedIndices in the sample) hold the selected points, so you can use them to update a grid, enable a button, or anything else you need.

    A note on the X axis: in our sample X is bound to a string field, so it is a category axis and the point index is used as the X value. If your X values are numeric or dates, GetValues(1) returns them (dates as OADate doubles) and the same comparison works.

    Please let us know if it helps.

    Regards,

    Uttkarsh

  • Posted 2 October 2026, 12:55 am EST

    Uttkarsh,

    Thank you so much… I will give it a try.

    Hai

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels