<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:dx="http://schemas.devexpress.com/maui"
             x:Class="CrmDemo.Views.Dashboards.OrderStateEvolutionPage"
             xmlns:dshViewModels="clr-namespace:CrmDemo.ViewModels.Dashboards"
             xmlns:local="clr-namespace:CrmDemo.Views.Dashboards"
             Title="Order Aging">
    <ContentPage.BindingContext>
        <dshViewModels:OrdersStateEvolutionViewModel/>
    </ContentPage.BindingContext>
    <ContentPage.Resources>
        <local:StackedBarColorConverter x:Key="stackedBarColorConverter"/>
    </ContentPage.Resources>
    <Grid>
        <dx:ChartView>
            <dx:ChartView.SeriesDataTemplate>
                <dx:SeriesTemplateAdapter DataSource="{Binding DataItems}" SeriesDataMember="State" ArgumentDataMember="DateString">
                    <dx:SeriesTemplateAdapter.ValueDataMembers>
                        <dx:ValueDataMember Type="Value" Member="Revenue"/>
                    </dx:SeriesTemplateAdapter.ValueDataMembers>
                    <dx:SeriesTemplateAdapter.SeriesTemplate>
                        <DataTemplate>
                            <dx:FullStackedBarSeries DisplayName="{Binding Path=SeriesDataMemberValue}" VisibleInLegend="True">
                                <dx:StackedBarSeries.Style>
                                    <dx:BarSeriesStyle Fill="{Binding Path=., Converter={StaticResource stackedBarColorConverter}}" />
                                </dx:StackedBarSeries.Style>
                            </dx:FullStackedBarSeries>
                        </DataTemplate>
                    </dx:SeriesTemplateAdapter.SeriesTemplate>
                </dx:SeriesTemplateAdapter>
            </dx:ChartView.SeriesDataTemplate>

            <dx:ChartView.AxisY>
                <dx:NumericAxisY>
                    <dx:NumericAxisY.Label>
                        <dx:AxisLabel TextFormat="#%"/>
                    </dx:NumericAxisY.Label>
                </dx:NumericAxisY>
            </dx:ChartView.AxisY>

            <dx:ChartView.Legend>
                <dx:Legend HorizontalPosition="Right" VerticalPosition="Top" Orientation="LeftToRight" />
            </dx:ChartView.Legend>
            <dx:ChartView.Hint>
                <dx:Hint/>
            </dx:ChartView.Hint>

            <dx:ChartView.ChartStyle>
                <dx:ChartStyle BackgroundColor="{dx:ThemeColor Surface}" />
            </dx:ChartView.ChartStyle>
        </dx:ChartView>
    </Grid>
</ContentPage>
