Data Visualization and Analysis — Tips and Tricks (August - September 2022)

This post includes a series of interesting support tickets answered throughout August and September. We hope you find the contents of this post interesting and of business value. Should you have any questions about a particular support ticket, feel free to post a comment in the DevExpress Support Center.
 

Tips & Tricks

BI Dashboard

BI Dashboard for Web Forms

BI Dashboard for WPF

  • T1117647 - How to add custom template to Series Labels of the Chart dashboard item
    https://supportcenter.devexpress.com/ticket/details/t1117647

    You can override ChartItemStyle to customize nested instances of the ChartControl and associated series options. The folowing code snippet modifies the SeriesLabel.ResolveOverlappingMode option:

    
    private void ChartControl_BoundDataChanged(object sender, RoutedEventArgs e) {
        var chart = (ChartControl)sender;
        var d = (XYDiagram2D)chart.Diagram;
    
        for (int i = 0; i < d.Series.Count; i++) {
            var label = new SeriesLabel();
            label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped;
            label.ElementTemplate = (DataTemplate)this.FindResource("labelTemplate");
            d.Series[i].Label = label;
        }
    }
    
    
    <dx:ThemedWindow.Resources>
        <DataTemplate x:Key="labelTemplate">
            <Label Content="{Binding Path=Text}" Background="LightYellow" BorderThickness="0"/>
        </DataTemplate>
        <DataTemplate x:Key="chartTemplate">
            <dxc:ChartControl Style="{Binding Path=(dxdash:DashboardLayoutItem.ViewStyle), 
            	RelativeSource={RelativeSource TemplatedParent}}"
                BoundDataChanged="ChartControl_BoundDataChanged">
            </dxc:ChartControl>
        </DataTemplate>
    </dx:ThemedWindow.Resources>
    <Grid>
        <dxdash:DashboardControl x:Name="dashboardControl1">
            <dxdash:DashboardControl.ChartItemStyle>
                <Style TargetType="dxdash:ChartDashboardLayoutItem">
                    <Setter Property="ContentTemplate" Value="{StaticResource chartTemplate}"/>
                </Style>
            </dxdash:DashboardControl.ChartItemStyle>
        </dxdash:DashboardControl>
    </Grid>
    

Chart for WinForms

Chart for WPF

  • T1116213 - How to get the position of a point via a click event on a 2DChart using MVVM patterns
    https://supportcenter.devexpress.com/ticket/details/t1116213

    The correct MVVM approach is to use EventToCommand behavior. Event argument conversion is implemented in the CustomMouseButtonEventArgsConverter.Convert method.

    
    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:EventToCommand
        	Command="{Binding ClickCommand}"
            EventName="MouseDown"
            PassEventArgsToCommand="True"
            EventArgsConverter="{local:CustomMouseButtonEventArgsConverter}"/>
    </dxmvvm:Interaction.Behaviors>
    
    
    public ICommand ClickCommand { get; } = new DelegateCommand(OnClick);
    
    private static void OnClick(Point coordinates) {
    	MessageBox.Show(coordinates.ToString());
    }
    
  • T1115869 - How to get selected item info on XYDiagram2D
    https://supportcenter.devexpress.com/ticket/details/t1115869

  • T1112366 - How to display custom labels for logarithmic x-axis
    https://supportcenter.devexpress.com/ticket/details/t1112366

    To customize the display of axis labels, define Custom Labels as follows:

    
    var label = new CustomAxisLabel(d.sieb, d.sieb.ToString());
    ((XYDiagram2D)chartControl2.Diagram).AxisX.CustomLabels.Add(label);
    

Chart for Web Forms

Map for WPF

Pivot Grid for WinForms

Enhancements

Chart for WinForms and WPF

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.