<commit_before>import { Injectable } from '@angular/core';
import { ChartOptionsService } from './chart-options.service';
declare let fc:any;
declare let d3:any;
@Injectable()
export class ChartTooltipsService {
  constructor(private chartOptionsService:ChartOptionsService) {
  }

  getLastClose():any {
    return fc.annotation.line()
      .value((d:any) => {
        return d.close;
      })
      .label((d:any) => {
        return this.chartOptionsService.options.priceFormat(d.close);
      })
      .decorate((sel:any) => {
        this.addYTooltip(sel);
        sel.enter().classed('close', true);
      });
  }

  addYTooltip(sel:any) {
    sel.enter()
      .select('.right-handle')
      .classed('callout', true)
      .insert('path', ':first-child')
      .attr('transform', 'translate(' + this.chartOptionsService.options.calloutLeftMargin + ', 0)')
      .attr('d', d3.svg.area()(this.chartOptionsService.options.calloutPathData));
<commit_msg>Added logic to correctly align the close callout.<commit_after>import { Injectable } from '@angular/core';
import { ChartOptionsService } from './chart-options.service';
declare let fc:any;
declare let d3:any;
@Injectable()
export class ChartTooltipsService {
  constructor(private chartOptionsService:ChartOptionsService) {
  }

  getLastClose():any {
    return fc.annotation.line()
      .value((d:any) => {
        return d.close;
      })
      .label((d:any) => {
        return this.chartOptionsService.options.priceFormat(d.close);
      })
      .decorate((sel:any) => {
        this.addYTooltip(sel);
        sel.enter().classed('close', true);

        sel.attr('transform', function (d:any) {
            let transform:string;
            if (d3.select('.line')) {
              let y:string = d3.select('.line').attr('d').match(/[^,]*$/)[0];
              if (y) {
                transform = 'translate(0, ' + y + ')';
              }
            }

            if (transform) {
              return transform;
            } else {
              return this.getAttribute('transform');
            }
          });
      });
  }

  addYTooltip(sel:any) {
    sel.enter()
      .select('.right-handle')
      .classed('callout', true)
      .insert('path', ':first-child')
      .attr('transform', 'translate(' + this.chartOptionsService.options.calloutLeftMargin + ', 0)')
      .attr('d', d3.svg.area()(this.chartOptionsService.options.calloutPathData));

{'fraction_non_alphanumeric': 0.16392092257001648, 'fraction_numerical': 0.004118616144975288, 'mean_word_length': 2.587887740029542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3143609', 'n_tokens_mistral': 747, 'n_tokens_neox': 738, 'n_words': 121}