<fim-prefix>                 height: 160,
                  colors: ['#009688'],
                  lineOptions: {
                    regionFill: 1,
                  },
                  data: {
                    labels:
                  [stats.beforePreviousMonthName,
                    stats.previousMonthName,
                    stats.currentMonthName],
                    datasets: [{
                      values:
                    [stats.beforePreviousMonthHours,
                      stats.previousMonthHours,
                      stats.currentMonthHours],
                    }],
                  },
                  tooltipOptions: {
                    formatTooltipY: (value) => `${value} ${getUserTimeUnitVerbose()}`,
                  },
                })
              }
            })
          }
        })
      }
      if (templateInstance.topTasks.get() && templateInstance.$('.js-pie-chart-container')[0] && templateInstance.$('.js-pie-chart-container').is(':visible')) {
        import('frappe-charts').then((chartModule) => {
          window.requestAnimationFrame(() => {
            const { Chart } = chartModule
            if (templateInstance.piechart) {
              templateInstance.piechart.destroy()
            }
            templateInstance.piechart = new Chart(templateInstance.$('.js-pie-chart-container')[0], {
              type: 'pie',
              colors: ['#009688', '#455A64', '#e4e4e4'],
              height: 230,
              data: {
                // BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
                // labels: templateInstance.topTasks.get().map((task) => task._id),
                // FIXED: 
<fim-middle>                labels: templateInstance.topTasks.get().map((task) => $('<span>').text(task._id).html()),
                datasets: [{
                  values: templateInstance.topTasks.get().map((tas<fix-suffix>k) => task.count),
                }],
              },
              tooltipOptions: {
              },
            })
          })
        })
      }
    }
  })
})
Template.allprojectschart.onDestroyed(() => {
  const templateInstance = Template.instance()
  if (templateInstance.chart) {
    templateInstance.chart.destroy()
  }
  if (templateInstance.piechart) {
    templateInstance.piechart.destroy()
  }
})
<|endoftext|>