import LineSeriesModel from './LineSeries.mjs';
import LineView from './LineView.mjs';
import pointsLayout from '../../layout/points.mjs';
import dataSample from '../../processor/dataSample.mjs';

function install(registers) {
  registers.registerChartView(LineView);
  registers.registerSeriesModel(LineSeriesModel);
  registers.registerLayout(pointsLayout('line', true));
  registers.registerVisual({
    seriesType: 'line',
    reset: function (seriesModel) {
      var data = seriesModel.getData();
      // Visual coding for legend
      var lineStyle = seriesModel.getModel('lineStyle').getLineStyle();
      if (lineStyle && !lineStyle.stroke) {
        // Fill in visual should be palette color if
        // has color callback
        lineStyle.stroke = data.getVisual('style').fill;
      }
      data.setVisual('legendLineStyle', lineStyle);
    }
  });
  // Down sample after filter
  registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, dataSample('line'));
}

export { install };
