{"size": 1257, "ext": "js", "max_stars_repo_path": "eln/annotations/ir.js", "max_stars_repo_name": "kjappelbaum/visualizer-helper", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "eln/annotations/ir.js", "max_issues_repo_name": "kjappelbaum/visualizer-helper", "max_issues_repo_issues_event_min_datetime": "2016-04-14T15:48:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-06T09:06:06.000Z", "max_forks_repo_path": "eln/annotations/ir.js", "max_forks_repo_name": "kjappelbaum/visualizer-helper", "max_forks_repo_forks_event_min_datetime": "2017-04-12T07:05:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-27T16:47:32.000Z"}
{"max_stars_count": null, "max_issues_count": 26, "max_forks_count": 6, "avg_line_length": 21.6724137931, "max_line_length": 61, "alphanum_fraction": 0.5274463007}
function toAnnotations(peaks, options = {}) {
  var { fillColor = 'green', strokeColor = 'red' } = options;

  if (!peaks) return [];
  let shouldRefresh = false;
  let annotations = peaks.map((peak) => {
    if (!peak._highlight) {
      Object.defineProperty(peak, '_highlight', {
        enumerable: false,
        writable: true
      });
      peak._highlight = Math.random();
      shouldRefresh = true;
    }
    var annotation = {
      line: 1,
      _highlight: [peak._highlight],
      type: 'rect',
      strokeColor: strokeColor,
      strokeWidth: 0,
      fillColor: fillColor
    };
    annotation.label = [
      {
        text: peak.kind,
        size: '18px',
        anchor: 'middle',
        color: 'red',
        position: {
          x: peak.wavelength,
          y: peak.transmittance,
          dy: '-22px'
        }
      }
    ];
    annotation.position = [
      {
        x: peak.wavelength - 10,
        y: peak.transmittance,
        dy: '-20px'
      },
      {
        x: peak.wavelength + 10,
        y: peak.transmittance,
        dy: '-10px'
      }
    ];
    return annotation;
  });

  if (shouldRefresh && peaks.triggerChange) {
    peaks.triggerChange();
  }
  return annotations;
}

module.exports = toAnnotations;
