Я не могу понять, как заставить мои графики работать. Я подготовил данные, но каждый раз, когда я, например, добавляю метки (labelDate), они просто дают мне неопределенную переменную, когда я ее регистрирую.
ngOnInit(): void {
let labelDate;
this._estimateService.getEstimates()
.subscribe(estimateData => {
const key = 'data';
const groupedEstimates = groupBy(estimateData[key], 'estimate_date');
// console.log(groupedEstimateData);
const groupedEstimatesFiltered = omit(groupedEstimates, 'null');
Object.entries(groupedEstimatesFiltered)
.map(([date, estimatedData]) => {
labelDate = moment(date).format('DD MMM'); // Change it here
console.log(labelDate, estimatedData.length + ' - this is the first log');
});
});
if (!this.data) {
const color = Chart.helpers.color;
this.data = {
labels: [labelDate], // Doesnt work - logs as undefined
datasets: [
{
data: [estimateData.length] // Same as above
},
Как выглядит журнал набора данных:
