Ticket T657508
Visible to All Users

ChartControl - How to select a SeriesPoint when clicking the legend item label

created 7 years ago

Hello,

my goal is that a user can filter the data by clicking on a legend label
(just like selecting a series by clicking in the pie chart itself).

I am using a hit-test in the MouseClick-event which works fine.
The only downside is that there is no visual feedback  that a series is "selected" / there is no highlighting-
just like when i  click directly in the pie chart.

How can i achieve this via code?

Thank you!

Answers approved by DevExpress Support

created 7 years ago

Hello,

To implement this task, I suggest you enable chart selection by setting the ChartControl.SelectionMode property to Single and ChartControl.SeriesSelectionMode to Point. To select the required point in code, use the ChartControl.SelectedItems property.
Should you have any further questions, feel free to contact us.

    Show previous comments (4)
    DevExpress Support Team 7 years ago

      Hello,

      Thank you for the clarification. To select the required point on the legend item label click, I suggest you turn-off the Chart selection by setting the SelectionMode property to None and modify your code in the following manner:

      C#
      private void chartControl1_MouseDown(object sender, MouseEventArgs e) { ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.Location); // if (hitInfo.InLegend && !hitInfo.InSeries) uncomment to select only by the labels click { if (hitInfo.SeriesPoint == null) return; chartControl1.ClearSelection(); chartControl1.SelectedItems.Add(chartControl1.Series[0].Points.FirstOrDefault(r => r.ArgumentX.NumericalArgument == hitInfo.SeriesPoint.NumericalArgument)); } }

      Attached is the modified project. I hope it will be helpful.

        Thank you!

        This one works like a a charm.

        DevExpress Support Team 7 years ago

          You are welcome! I am happy to hear that my assistance was helpful. Please feel free to contact us at any time.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.