-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some clean up POC for adding version info to application
- Loading branch information
Showing
18 changed files
with
392 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
RadiocomDataViewApp/Components/ArtistWorkCharts/SongPercentageOfArtistPieChart.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
<CascadingValue Value="@HeaderButtonConfigs" Name="HeaderButtonConfigs"> | ||
|
||
|
||
<DashboardPieChartComponent @ref="Chart" | ||
ChartTitle="@DashboardPieChartComponentTitle" | ||
GenerateChartDatas="SongPercentageOfArtist" | ||
SliceColorGenerator="SliceColorGenerator" | ||
OnDashboardPieChartClick="OnDashboardPieChartClick"/> | ||
</CascadingValue> |
81 changes: 81 additions & 0 deletions
81
RadiocomDataViewApp/Components/ArtistWorkCharts/SongPercentageOfArtistPieChart.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Blazorise; | ||
using Blazorise.Charts; | ||
using Microsoft.AspNetCore.Components; | ||
using RadiocomDataViewApp.Clients; | ||
using RadiocomDataViewApp.Interfaces; | ||
using RadiocomDataViewApp.Objects; | ||
|
||
namespace RadiocomDataViewApp.Components.ArtistWorkCharts | ||
{ | ||
public partial class SongPercentageOfArtistPieChart : ComponentBase | ||
{ | ||
private DashboardPieChartComponent Chart; | ||
private List<HeaderButtonState> HeaderButtonConfigs { get; set; } | ||
|
||
private AggregateTimeRange ChartDataTimeRange = AggregateTimeRange.SevenDays; | ||
|
||
[Parameter] | ||
public int ArtistWorkId { get; set; } | ||
[Parameter] | ||
public string ArtistName { get; set; } | ||
|
||
[Parameter] | ||
public int ArtistId { get; set; } | ||
|
||
[Inject] | ||
public IRadiocomDataAggregateDataClient RadiocomDataAggregateDataClient { get; set; } | ||
[Inject] | ||
public NavigationManager NavManager { get; set; } | ||
|
||
public SongPercentageOfArtistPieChart() | ||
{ | ||
HeaderButtonConfigs = new List<HeaderButtonState>() | ||
{ | ||
new HeaderButtonState(){Text = "7 Days",ButtonColor=Color.Secondary,Active=true, ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.SevenDays)) } , | ||
new HeaderButtonState(){Text = "3 Months", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.ThreeMonths)) } , | ||
new HeaderButtonState(){Text = "All Time", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.AllTime)) } | ||
}; | ||
|
||
ChartDataTimeRange = AggregateTimeRange.SevenDays; | ||
} | ||
private void UpdateChartDataTimeRange(AggregateTimeRange mostPlayedTimeRange) | ||
{ | ||
ChartDataTimeRange = mostPlayedTimeRange; | ||
Console.Write("djfoisajfiodsajfa\n\n\n"); | ||
Chart.RefreshChartData(); | ||
} | ||
private IEnumerable<DashboardChartData> SongPercentageOfArtist() | ||
{ | ||
List<ItemCount> radioComData = RadiocomDataAggregateDataClient.GetSongPlayedAndOtherPlayed(ChartDataTimeRange, ArtistWorkId); | ||
return radioComData.Select(x => new DashboardChartData() { Label = x.Name, Value = x.Count, DataId = x.ItemId }); | ||
|
||
} | ||
|
||
private ChartColor SliceColorGenerator(int indx) | ||
{ | ||
ChartColor color; | ||
if (indx == 0) | ||
{ | ||
color = OtherSongsPieChartColor; | ||
} | ||
else | ||
{ | ||
color = ViewedSongPieChartColor; | ||
} | ||
return color; | ||
} | ||
private void OnDashboardPieChartClick() | ||
{ | ||
NavManager.NavigateTo($"/artist/{ArtistId}/artistworks"); | ||
} | ||
private static readonly ChartColor ViewedSongPieChartColor = ChartColor.FromRgba(255, 255, 255, 1);//white | ||
private static readonly ChartColor OtherSongsPieChartColor = ChartColor.FromRgba(104, 104, 103, 1);//grey | ||
|
||
private string DashboardPieChartComponentTitle => $" Comparison with Other Songs Played by {ArtistName}"; | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
RadiocomDataViewApp/Components/ArtistWorkCharts/SongPlayedOverTimeChart.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<CascadingValue Value="@HeaderButtonConfigs" Name="HeaderButtonConfigs"> | ||
|
||
|
||
<DashboardLineGraphChartComponent @ref="Chart" | ||
ChartTitle="Song Played Over Time" | ||
XAxisLabel="XLabel" | ||
GenerateChartDatas="SongPlayedOverTime" /> | ||
</CascadingValue> |
49 changes: 49 additions & 0 deletions
49
RadiocomDataViewApp/Components/ArtistWorkCharts/SongPlayedOverTimeChart.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Blazorise; | ||
using Microsoft.AspNetCore.Components; | ||
using RadiocomDataViewApp.Clients; | ||
using RadiocomDataViewApp.Interfaces; | ||
using RadiocomDataViewApp.Objects; | ||
|
||
namespace RadiocomDataViewApp.Components.ArtistWorkCharts | ||
{ | ||
public partial class SongPlayedOverTimeChart : ComponentBase | ||
{ | ||
private DashboardLineGraphChartComponent Chart; | ||
private List<HeaderButtonState> HeaderButtonConfigs { get; set; } | ||
|
||
private AggregateTimeRange ChartDataTimeRange = AggregateTimeRange.SevenDays; | ||
|
||
[Parameter] | ||
public int ArtistWorkId { get; set; } | ||
|
||
[Inject] | ||
public IRadiocomDataAggregateDataClient RadiocomDataAggregateDataClient { get; set; } | ||
|
||
public SongPlayedOverTimeChart() | ||
{ | ||
HeaderButtonConfigs = new List<HeaderButtonState>() | ||
{ | ||
new HeaderButtonState(){Text = "7 Days",ButtonColor=Color.Secondary,Active=true, ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.SevenDays)) } , | ||
new HeaderButtonState(){Text = "3 Months", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.ThreeMonths)) } , | ||
new HeaderButtonState(){Text = "All Time", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.AllTime)) } | ||
}; | ||
|
||
ChartDataTimeRange = AggregateTimeRange.SevenDays; | ||
} | ||
private void UpdateChartDataTimeRange(AggregateTimeRange mostPlayedTimeRange) | ||
{ | ||
ChartDataTimeRange = mostPlayedTimeRange; | ||
Chart.RefreshChartData(); | ||
} | ||
private IEnumerable<DashboardChartData> SongPlayedOverTime() | ||
{ | ||
List<ItemCount> radioComData = RadiocomDataAggregateDataClient.GetSongPlayedOverTime(ChartDataTimeRange, ArtistWorkId); | ||
return radioComData.Select(x => new DashboardChartData() { Label = x.Name, Value = x.Count, DataId = x.ItemId }); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
RadiocomDataViewApp/Components/DashboardPieChartComponent.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Card> | ||
<CardHeader> | ||
@if (!String.IsNullOrEmpty(ChartTitle)) | ||
{ | ||
<Container Fluid="true" Style="text-align:center"> | ||
<Heading Size="HeadingSize.Is5" Alignment="TextAlignment.None">@ChartTitle</Heading> | ||
</Container> | ||
} | ||
</CardHeader> | ||
<CardBody> | ||
|
||
<ChartComponentHeaderButtons /> | ||
|
||
|
||
|
||
<PieChart @ref="Chart" TItem="int" OptionsObject="@ChartOptionsObj" Clicked="OnPieChartClick" /> | ||
</CardBody> | ||
|
||
</Card> |
137 changes: 137 additions & 0 deletions
137
RadiocomDataViewApp/Components/DashboardPieChartComponent.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Blazorise.Charts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using RadiocomDataViewApp.Objects; | ||
|
||
namespace RadiocomDataViewApp.Components | ||
{ | ||
public partial class DashboardPieChartComponent : ComponentBase | ||
{ | ||
private const string DEFAULT_SLICE_COLOR = "#FFF"; | ||
|
||
private PieChart<int> Chart; | ||
public readonly object ChartOptionsObj; | ||
|
||
|
||
|
||
[Parameter] | ||
public string ChartTitle { get; set; } | ||
[Parameter] | ||
public Func<IEnumerable<DashboardChartData>> GenerateChartDatas { get; set; } | ||
[Parameter] | ||
public Func<int, ChartColor> SliceColorGenerator { get; set; } | ||
|
||
/// <summary> | ||
/// event for clicking specfically on the PieChart | ||
/// </summary> | ||
[Parameter] | ||
public EventCallback<DashboardChartMouseEventArgs> OnDashboardPieChartClick { get; set; } | ||
|
||
public DashboardPieChartComponent() | ||
{ | ||
#region chartOptions | ||
ChartOptionsObj = new | ||
{ | ||
Legend = new { Display = false }, | ||
//Scales = new | ||
//{ | ||
// YAxes = new object[] | ||
// { | ||
// new | ||
// { | ||
// ScaleLabel = new | ||
// { | ||
// FontColor = GetScaleFontColor(), | ||
// Display = true, | ||
// LabelString = YAxisLabel ?? string.Empty | ||
// }, | ||
// Ticks = StandardTicks | ||
|
||
// } | ||
// }, | ||
// XAxes = new object[] | ||
// { | ||
// new | ||
// { | ||
// ScaleLabel = new | ||
// { | ||
// FontColor = GetScaleFontColor(), | ||
// Display = true, | ||
// LabelString = XAxisLabel ?? string.Empty | ||
// }, | ||
// Ticks = StandardTicks | ||
// } | ||
// } | ||
//}, | ||
AspectRatio = 1.5 | ||
|
||
}; | ||
#endregion chartOptions | ||
} | ||
|
||
public void RefreshChartData() | ||
{ | ||
Console.WriteLine("refresh picharet"); | ||
IEnumerable<DashboardChartData> newDatas = GenerateChartDatas?.Invoke(); | ||
Chart.Clear(); | ||
Chart.AddLabels(newDatas.Select(x => x.Label).ToArray()); | ||
|
||
List<string> colors = new List<string>(); | ||
for (int i = 0; i < newDatas.Count(); i++) | ||
{ | ||
string sliceColor = SliceColorGenerator?.Invoke(i); | ||
if (!string.IsNullOrWhiteSpace(sliceColor)) | ||
{ | ||
colors.Add(sliceColor); | ||
} | ||
else | ||
{ | ||
colors.Add(DEFAULT_SLICE_COLOR); | ||
} | ||
} | ||
|
||
PieChartDataset<int> newChartDataset = new PieChartDataset<int>() | ||
{ | ||
Data = newDatas.Select(x => x.Value).ToList(), | ||
BackgroundColor = colors, | ||
BorderColor = colors | ||
}; | ||
newChartDataset.HoverBackgroundColor.Clear(); | ||
newChartDataset.HoverBorderColor.Clear(); | ||
CurrentDataset = newChartDataset; | ||
Chart.AddDataSet(newChartDataset); | ||
Chart.Update(); | ||
} | ||
|
||
protected override void OnAfterRender(bool firstRender) | ||
{ | ||
base.OnAfterRender(firstRender); | ||
if (firstRender) | ||
{ | ||
Console.Write("ridnejejf"); | ||
RefreshChartData(); | ||
} | ||
} | ||
|
||
//private async Task OnSliceElementClickedHandler(ChartMouseEventArgs args) | ||
//{ | ||
|
||
// DashboardChartMouseEventArgs chartMouseEventArgs = new DashboardChartMouseEventArgs(args.DatasetIndex, args.Index, args.Model); | ||
// chartMouseEventArgs.DatasetElement = CurrentDataset.Data[args.Index]; | ||
// await OnDashboardChartElementClick.InvokeAsync(chartMouseEventArgs); | ||
//} | ||
|
||
private async Task OnPieChartClick(ChartMouseEventArgs args) | ||
{ | ||
DashboardChartMouseEventArgs chartMouseEventArgs = new DashboardChartMouseEventArgs(args.DatasetIndex, args.Index, args.Model); | ||
chartMouseEventArgs.DatasetElement = CurrentDataset.Data[chartMouseEventArgs.Index]; | ||
await OnDashboardPieChartClick.InvokeAsync(chartMouseEventArgs); | ||
} | ||
|
||
protected PieChartDataset<int> CurrentDataset { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.