Fix channel chart accessibility

pull/6648/head
Chocobozzz 2024-09-19 15:49:33 +02:00
parent 5459364b19
commit 16ea7aef8a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 19 additions and 3 deletions

View File

@ -61,6 +61,7 @@
*ngIf="chartOptions && videoChannelsChartData && videoChannelsChartData[i]"
width="40vw" height="100px"
type="line" [data]="videoChannelsChartData[i]" [options]="chartOptions"
[ariaLabel]="getChartAriaLabel(videoChannelsChartData[i])"
></p-chart>
</ng-template>
</div>

View File

@ -19,6 +19,8 @@ import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-b
import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'
import { ChannelsSetupMessageComponent } from '../../shared/shared-main/misc/channels-setup-message.component'
type CustomChartData = (ChartData & { startDate: string, total: number })
@Component({
templateUrl: './my-video-channels.component.html',
styleUrls: [ './my-video-channels.component.scss' ],
@ -42,7 +44,7 @@ import { ChannelsSetupMessageComponent } from '../../shared/shared-main/misc/cha
export class MyVideoChannelsComponent {
videoChannels: VideoChannel[] = []
videoChannelsChartData: ChartData[]
videoChannelsChartData: CustomChartData[]
chartOptions: ChartOptions
@ -146,8 +148,15 @@ export class MyVideoChannelsComponent {
fill: false,
borderColor: '#c6c6c6'
}
]
} as ChartData))
],
total: v.viewsPerDay.map(day => day.views)
.reduce((p, c) => p + c, 0),
startDate: v.viewsPerDay.length !== 0
? v.viewsPerDay[0].date.toLocaleDateString()
: ''
}))
this.buildChartOptions()
@ -207,4 +216,10 @@ export class MyVideoChannelsComponent {
}
}
}
getChartAriaLabel (data: CustomChartData) {
if (!data.startDate) return ''
return formatICU($localize`${data.total} {value, plural, =1 {view} other {views}} since ${data.startDate}`, { value: data.total })
}
}