<?xml version="1.0" encoding="utf-8"?>
<navigation:Page x:Class="SalesAnalysis.Charts" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" Style="{StaticResource PageStyle}" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:local="clr-namespace:SalesAnalysis.Web" xmlns:c1="clr-namespace:C1.Silverlight.Chart;assembly=C1.Silverlight.Chart.5">

    <Grid x:Name="LayoutRoot">

        <!-- domain data sources for the charts -->
        <riaControls:DomainDataSource Name="_ddsSalesByCountry" QueryName="GetSalesByCountry" AutoLoad="True">
            <riaControls:DomainDataSource.DomainContext>
                <local:NorthWindDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
        <riaControls:DomainDataSource x:Name="_ddsSalesByProduct" QueryName="GetSalesByProduct" AutoLoad="True">
            <riaControls:DomainDataSource.DomainContext>
                <local:NorthWindDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>

        <Grid Style="{StaticResource ContentStackPanelStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <StackPanel x:Name="ContentStackPanel">
                <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="{Binding Path=ApplicationStrings.ChartsPageTitle, Source={StaticResource ResourceWrapper}}" />
                <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" Text="Sales By Country and by Product (top 15)" />
            </StackPanel>

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <c1:C1Chart Name="_chartByCountry" Margin="4 20" Aggregate="Sum" ChartType="Bar" Palette="Office">
                    <c1:C1Chart.View>
                        <c1:ChartView>
                            <c1:ChartView.AxisY>
                                <c1:Axis Reversed="True" />
                            </c1:ChartView.AxisY>
                        </c1:ChartView>
                    </c1:C1Chart.View>
                    <c1:C1Chart.Data>
                        <c1:ChartData ItemsSource="{Binding Data, ElementName=_ddsSalesByCountry}" ItemNameBinding="{Binding Item}">
                            <c1:DataSeries ValueBinding="{Binding Amount}" />
                        </c1:ChartData>
                    </c1:C1Chart.Data>
                </c1:C1Chart>
                
                <c1:C1Chart Name="_chartByProduct" Grid.Column="1" Margin="4 20" Aggregate="Sum" ChartType="Bar" Palette="Oriel">
                    <c1:C1Chart.View>
                        <c1:ChartView>
                            <c1:ChartView.AxisY>
                                <c1:Axis Reversed="True" />
                            </c1:ChartView.AxisY>
                        </c1:ChartView>
                    </c1:C1Chart.View>
                    <c1:C1Chart.Data>
                        <c1:ChartData ItemsSource="{Binding Data, ElementName=_ddsSalesByProduct}" ItemNameBinding="{Binding Item}">
                            <c1:DataSeries ValueBinding="{Binding Amount}" />
                        </c1:ChartData>
                    </c1:C1Chart.Data>
                </c1:C1Chart>
            </Grid>

            <!-- status bar -->
            <TextBlock Name="_tbStatus" Grid.Row="3" HorizontalAlignment="Right" Margin="0 6 0 4" />
            <TextBlock Grid.Row="3" Text=" " Margin="0 6 0 4" />

        </Grid>
    </Grid>
</navigation:Page>