/** The PieChartFilterInputProcessor class filters out any items in the input dataSource that do not have a name and value property for a pie chart. */
export class PieChartFilterInputProcessor {
  /**
   * This function filters out any items in the input dataSource that do not have a name and value property.
   *
   * @param {ChartOptions<PieChartSourceType>} input - The input parameter is of type ChartOptions<PieChartSourceType>, which is an object
   * containing options for a pie chart. It includes properties such as the chart title, data source,
   * and chart configuration options. The function is designed to filter out any data items in the data
   * source that do not have a name or value
   * @returns {ChartOptions<PieChartSourceType>} the modified input object of type `ChartOptions<PieChartSourceType>`.
   */
  process(input) {
    const filterDataSource = input.dataSource.filter((item) => !!(item.name && item.value));
    input.dataSource = filterDataSource;
    return input;
  }
}
