@using Radzen.Blazor
@using System.Collections.Generic

<div class="rz-p-0 rz-p-md-12">
    <RadzenCard Variant="Variant.Outlined" class="rz-mb-12">
        <RadzenStack Orientation="Orientation.Vertical" Gap="0.25rem">
            <RadzenLabel Text="Color scheme:" Component="ColorScheme" />
            <RadzenDropDown @bind-Value="@colorScheme" Data="@colorSchemes" Name="ColorScheme">
                <Template Context="scheme">
                    @Enum.GetName(typeof(ColorScheme), scheme)
                </Template>
            </RadzenDropDown>
        </RadzenStack>
    </RadzenCard>
    <RadzenSankeyDiagram TItem="FlowData"
                         Data="@flows"
                         SourceProperty="Source"
                         TargetProperty="Target"
                         ValueProperty="Value"
                         SourceLabelProperty="SourceLabel"
                         TargetLabelProperty="TargetLabel"
                         ColorScheme="@colorScheme">
    </RadzenSankeyDiagram>
</div>

@code {
    public class FlowData
    {
        public string Source { get; set; }
        public string Target { get; set; }
        public double Value { get; set; }
        public string SourceLabel { get; set; }
        public string TargetLabel { get; set; }
    }

    private ColorScheme colorScheme = ColorScheme.Pastel;
    private IEnumerable<ColorScheme> colorSchemes = Enum.GetValues(typeof(ColorScheme)).Cast<ColorScheme>();

    private List<FlowData> flows = new List<FlowData>
    {
        new FlowData { Source = "products", SourceLabel = "Product Sales", Target = "marketing", TargetLabel = "Marketing", Value = 150 },
        new FlowData { Source = "products", SourceLabel = "Product Sales", Target = "engineering", TargetLabel = "Engineering", Value = 280 },
        new FlowData { Source = "products", SourceLabel = "Product Sales", Target = "operations", TargetLabel = "Operations", Value = 70 },
        new FlowData { Source = "services", SourceLabel = "Consulting Services", Target = "marketing", TargetLabel = "Marketing", Value = 100 },
        new FlowData { Source = "services", SourceLabel = "Consulting Services", Target = "engineering", TargetLabel = "Engineering", Value = 160 },
        new FlowData { Source = "licensing", SourceLabel = "Licensing Fees", Target = "engineering", TargetLabel = "Engineering", Value = 80 },
        new FlowData { Source = "licensing", SourceLabel = "Licensing Fees", Target = "operations", TargetLabel = "Operations", Value = 50 },
        new FlowData { Source = "licensing", SourceLabel = "Licensing Fees", Target = "marketing", TargetLabel = "Marketing", Value = 30 },
    };
}
