-
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.
Starting Artist and ArtistWork pages with mocked data.
creating new dashboard chart for line graph some clean up
- Loading branch information
Showing
27 changed files
with
440 additions
and
60 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
10 changes: 10 additions & 0 deletions
10
RadiocomDataViewApp/Components/ArtistCharts/TopPlayedArtistSongsChart.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"> | ||
<DashboardHorizontalBarChartComponent @ref="Chart" | ||
YAxisLabel="YLabel" | ||
GenerateChartDatas="TopPlayedArtistSongs" | ||
ChartTitle="Top Played Songs" | ||
OnDashboardChartElementClick="NavigateToArtistArtistsWorkRouteOnBarClick" /> | ||
</CascadingValue> | ||
|
||
|
60 changes: 60 additions & 0 deletions
60
RadiocomDataViewApp/Components/ArtistCharts/TopPlayedArtistSongsChart.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,60 @@ | ||
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.ArtistCharts | ||
{ | ||
public partial class TopPlayedArtistSongsChart : ComponentBase | ||
{ | ||
private List<HeaderButtonState> HeaderButtonConfigs; | ||
private AggregateTimeRange ChartDataTimeRange; | ||
private DashboardHorizontalBarChartComponent Chart; | ||
|
||
[Parameter] | ||
public int ArtistId { get; set; } | ||
|
||
[Inject] | ||
public NavigationManager NavManager { get; set; } | ||
[Inject] | ||
public IRadiocomDataAggregateDataClient RadiocomDataAggregateDataClient { get; set; } | ||
|
||
|
||
|
||
public TopPlayedArtistSongsChart() | ||
{ | ||
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 NavigateToArtistArtistsWorkRouteOnBarClick(DashboardChartMouseEventArgs args) | ||
{ | ||
BarChartDatasetXValue element = (BarChartDatasetXValue)args.DatasetElement; | ||
NavManager.NavigateTo($"artist/{element.DataId}/works"); | ||
} | ||
|
||
private void UpdateChartDataTimeRange(AggregateTimeRange mostPlayedTimeRange) | ||
{ | ||
ChartDataTimeRange = mostPlayedTimeRange; | ||
Chart.RefreshChartData(); | ||
} | ||
|
||
private IEnumerable<DashboardChartData> TopPlayedArtistSongs() | ||
{ | ||
List<ItemCount> radioComData = RadiocomDataAggregateDataClient.GetMostPlayedSongs(ChartDataTimeRange, ArtistId); | ||
return radioComData.Select(x => new DashboardChartData() { Label = x.Name, Value = x.Count, DataId = x.ItemId }); | ||
} | ||
} | ||
} |
File renamed without changes.
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/DashboardLineGraphChartComponent.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 /> | ||
|
||
|
||
|
||
<LineChart @ref="Chart" TItem="DashboardChartDatasetYValue" OptionsObject="@ChartOptionsObj" /> | ||
</CardBody> | ||
|
||
</Card> |
142 changes: 142 additions & 0 deletions
142
RadiocomDataViewApp/Components/DashboardLineGraphChartComponent.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,142 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Blazorise.Charts; | ||
using Microsoft.AspNetCore.Components; | ||
using RadiocomDataViewApp.Objects; | ||
|
||
namespace RadiocomDataViewApp.Components | ||
{ | ||
public partial class DashboardLineGraphChartComponent : ComponentBase | ||
{ | ||
private const string DEFAULT_POINT_COLOR = "#FFF"; | ||
private const string DEFAULT_FILL_COLOR = "#555FAF"; | ||
|
||
private Object StandardTicks = new | ||
{ | ||
FontColor = "#fff", | ||
BeginAtZero = true | ||
}; | ||
public readonly ChartOptions chartOptions; | ||
public readonly object ChartOptionsObj; | ||
|
||
private LineChart<DashboardChartDatasetYValue> Chart; | ||
|
||
[Parameter] | ||
public string FillColor { get; set; } | ||
|
||
[Parameter] | ||
public string YAxisLabel { get; set; } | ||
[Parameter] | ||
public string XAxisLabel { get; set; } | ||
[Parameter] | ||
public string ChartTitle { get; set; } | ||
[Parameter] | ||
public Func<int, ChartColor> PointColorGenerator { get; set; } | ||
[Parameter] | ||
public Func<IEnumerable<DashboardChartData>> GenerateChartDatas { get; set; } | ||
[Parameter] | ||
public string ScaleLabelFontColor { get; set; } | ||
public DashboardLineGraphChartComponent() | ||
{ | ||
#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 | ||
|
||
}; | ||
|
||
|
||
chartOptions = new ChartOptions() | ||
{ | ||
Scales = new Scales() | ||
{ | ||
YAxes = new List<Axis>() { new Axis() { Ticks = new AxisTicks() { FontColor = "#fff" }, ScaleLabel = new AxisScaleLabel() { FontColor = "#fff", Display = true, LabelString = "valueObj" } } }, | ||
XAxes = new List<Axis>() { new Axis() { Ticks = new AxisTicks() { FontColor = "#fff" }, ScaleLabel = new AxisScaleLabel() { FontColor = "#fff", Display = true, LabelString = "dimension" } } }, | ||
}, | ||
}; | ||
#endregion | ||
|
||
} | ||
|
||
public void RefreshChartData() | ||
{ | ||
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 lineColor = PointColorGenerator?.Invoke(i); | ||
if (!string.IsNullOrWhiteSpace(lineColor)) | ||
{ | ||
colors.Add(lineColor); | ||
} | ||
else | ||
{ | ||
colors.Add(DEFAULT_POINT_COLOR); | ||
} | ||
} | ||
|
||
LineChartDataset<DashboardChartDatasetYValue> newChartDataset = new LineChartDataset<DashboardChartDatasetYValue>() | ||
{ | ||
Data = newDatas.Select(x => new DashboardChartDatasetYValue() { Y = x.Value, DataId = x.DataId }).ToList(), | ||
Fill = true, | ||
BackgroundColor = DEFAULT_FILL_COLOR, | ||
PointBackgroundColor = colors, | ||
PointBorderColor = colors, | ||
PointRadius = 3.5f | ||
}; | ||
//newChartDataset.HoverBorderColor.Clear(); | ||
CurrentDataset = newChartDataset; | ||
Chart.AddDataSet(newChartDataset); | ||
Chart.Update(); | ||
} | ||
protected LineChartDataset<DashboardChartDatasetYValue> CurrentDataset { get; set; } | ||
|
||
protected override void OnAfterRender(bool firstRender) | ||
{ | ||
base.OnAfterRender(firstRender); | ||
if (firstRender) | ||
{ | ||
RefreshChartData(); | ||
} | ||
} | ||
|
||
private string GetScaleFontColor() | ||
=> string.IsNullOrWhiteSpace(ScaleLabelFontColor) ? "#fff" : ScaleLabelFontColor; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
RadiocomDataViewApp/Components/IndexCharts/TopPlayedArtistsChart.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
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
2 changes: 1 addition & 1 deletion
2
RadiocomDataViewApp/Components/IndexCharts/TopPlayedSongsChart.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
Oops, something went wrong.