+ .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true)))
+ .subscribe(res => {
+ this.videoChannels = res.data
+
+ // chart data
+ this.videoChannelsChartData = this.videoChannels.map(v => ({
+ labels: v.viewsPerDay.map(day => day.date.toLocaleDateString()),
+ datasets: [
+ {
+ label: this.i18n('Views for the day'),
+ data: v.viewsPerDay.map(day => day.views),
+ fill: false,
+ borderColor: "#c6c6c6"
+ }
+ ]
+ } as ChartData))
+
+ // chart options that depend on chart data:
+ // we don't want to skew values and have min at 0, so we define what the floor/ceiling is here
+ this.videoChannelsMinimumDailyViews = min(
+ this.videoChannels.map(v => minBy( // compute local minimum daily views for each channel, by their "views" attribute
+ v.viewsPerDay,
+ day => day.views
+ ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute
+ )
+ this.videoChannelsMaximumDailyViews = max(
+ this.videoChannels.map(v => maxBy( // compute local maximum daily views for each channel, by their "views" attribute
+ v.viewsPerDay,
+ day => day.views
+ ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute
+ )
+ })