import * as Highcharts from 'highcharts';
import { BaseHighChartsRender } from "../types/BaseHighChartsRender";
export class PieChartStrategy extends BaseHighChartsRender {
  buildOptions(series, options) {
    const dataLabels = [
      {
        enabled: true,
        distance: 10
      },
      {
        enabled: true,
        distance: -40,
        format: '{point.percentage:.1f}%',
        style: {
          fontSize: '1.2em',
          textOutline: 'none',
          opacity: 0.7
        },
        filter: {
          property: 'percentage',
          operator: '>',
          value: 4
        }
      }
    ];
    return Object.assign(Object.assign(Object.assign(Object.assign({ chart: Object.assign(Object.assign({ type: 'pie' }, (options.width && { width: options.width })), (options.height && { height: options.height })), title: this.parseTitle(options.title) }, (options.subTitle && { subtitle: this.parseSubTitle(options.subTitle) })), { series: this.parseSerie(series), tooltip: this.buildFormatterTooltip(series), legend: {
        enabled: options.legendEnabled,
      }, plotOptions: {
        series: Object.assign({ dataLabels, cursor: 'pointer' }, (options.onClickSerie && {
          point: {
            events: {
              click: this.buildOnClickCallBack(options.onClickSerie),
            }
          }
        }))
      } }), this.buildResposiveConfig()), this.buildDefaultChartOptions());
  }
  render(container, series, _xAxis, _yAxis, options) {
    this.chart = Highcharts.chart(container, this.buildOptions(series, options));
  }
  destroy() {
    var _a;
    (_a = this.chart) === null || _a === void 0 ? void 0 : _a.destroy();
  }
}
