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
30
Select parts of an xamDataChart to apply some style like excel do using a ribbon
posted

I'm trying to get the xamDataChart more interactive for the user allowing to select some part of the chart and applying font properties to it.

- Chart Title

- axis labels

- axis titles

- Legend labels

- Annotations

- point labels

- etc.

is It posible? If it is true, what is the best way to do that?

  • 34430
    Offline posted

    Hello Hugev,

    I have been investigating into the requirement you are looking to achieve, and I can confirm that each of the pieces that you are looking to style for the XamDataChart can be styled, but there currently exists no UI for “selecting” the different parts of the chart at runtime to specifically style that part. This would be something that would need to be developed in application code for your application or potentially a feature to be implemented on our end.

    With the above said, doing this in application code also would not be the simplest thing, as many of the objects would be difficult to detect as there is no dedicated event for detecting a click on certain parts, such as the label panel where the axis labels and titles would be kept. Still, you could get these elements using the following code and hook a mouse event on them, like so:

    var horizPanel = Utilities.GetDescendantFromType(chart, typeof(HorizontalAxisLabelPanel), false) as HorizontalAxisLabelPanel;
    var vertPanel = Utilities.GetDescendantFromType(chart, typeof(VerticalAxisLabelPanel), false) as VerticalAxisLabelPanel;

    horizPanel.Background = Brushes.White;
    vertPanel.Background = Brushes.White;

    horizPanel.PreviewMouseDown += Panel_PreviewMouseDown;
    vertPanel.PreviewMouseDown += Panel_PreviewMouseDown;

    The setting of the Background is intentional as the default background is null, and as such would not detect mouse events. Keeping track of the state and whether or not the panel is selected or not would be something you would need to track here, though. I am also unsure of how you would determine whether the user wanted to style the axis labels or title in this case.

    From there though, you would set the LabelSettings property of your corresponding axis. Here is a link to our online documentation about styling the labels of the axes: https://www.infragistics.com/help/wpf/datachart-axis-label-settings.

    Detecting a click on the chart titles in this case would be tricky as well, as the chart title is essentially just a ContentControl that we place in the canvas of the chart and does not have its own element. You can read about modifying the style of the chart titles here: https://www.infragistics.com/help/wpf/datachart-axis-title.

    Regarding the Legend’s labels, I believe you should be able to handle a mouse event on the Legend to determine whether or not it is “selected” (again, it has no selected state – this will need to be defined by you) and then just modify the related font-properties on the Legend.

    Depending on what you are doing for your point labels and annotations, you may be able to utilize the SeriesMouseLeftButtonDown event of the chart to detect a click on these. Like the other pieces of the chart though, there is no selected state for these, and this is something you would need to track.

    If you would like to see ribbon interaction via selection of different parts of the XamDataChart potentially implemented as a feature, I would recommend suggesting a new product idea for this at our WPF Ideas Site, here: https://www.infragistics.com/community/ideas/i/ultimate-ui-for-wpf. This will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.

    Please let me know if you have any other questions or concerns on this matter.