<commit_before>/* eslint-disable ember/no-observers */
import Component from '@ember/component';
import { computed, set } from '@ember/object';
import { observes } from '@ember-decorators/object';
import { run } from '@ember/runloop';
import { assign } from '@ember/polyfills';
import { guidFor } from '@ember/object/internals';
import { copy } from 'ember-copy';
import d3 from 'd3-selection';
import 'd3-transition';
import WindowResizable from '../mixins/window-resizable';
import styleStringProperty from '../utils/properties/style-string';
import { classNames, classNameBindings } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';

const sumAggregate = (total, val) => total + val;

@classic
@classNames('chart', 'distribution-bar')
@classNameBindings('isNarrow:is-narrow')
export default class DistributionBar extends Component.extend(WindowResizable) {
  chart = null;
  // data = null; FIXME causing a getter-only exception
  activeDatum = null;
  isNarrow = false;

  @styleStringProperty('tooltipPosition') tooltipStyle;
  maskId = null;

  @computed('data')
  get _data() {
    const data = copy(this.data, true);
    const sum = data.mapBy('value').reduce(sumAggregate, 0);

    return data.map(({ label, value, className, layers }, index) => ({
      label,
      value,
      className,
      layers,<commit_msg>Data cannot be a field in the base class and a CP in the child classes<commit_after>/* eslint-disable ember/no-observers */
import Component from '@ember/component';
import { computed, set } from '@ember/object';
import { observes } from '@ember-decorators/object';
import { run } from '@ember/runloop';
import { assign } from '@ember/polyfills';
import { guidFor } from '@ember/object/internals';
import { copy } from 'ember-copy';
import { computed as overridable } from 'ember-overridable-computed';
import d3 from 'd3-selection';
import 'd3-transition';
import WindowResizable from '../mixins/window-resizable';
import styleStringProperty from '../utils/properties/style-string';
import { classNames, classNameBindings } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';

const sumAggregate = (total, val) => total + val;

@classic
@classNames('chart', 'distribution-bar')
@classNameBindings('isNarrow:is-narrow')
export default class DistributionBar extends Component.extend(WindowResizable) {
  chart = null;
  @overridable(() => null) data;
  activeDatum = null;
  isNarrow = false;

  @styleStringProperty('tooltipPosition') tooltipStyle;
  maskId = null;

  @computed('data')
  get _data() {
    const data = copy(this.data, true);
    const sum = data.mapBy('value').reduce(sumAggregate, 0);

    return data.map(({ label, value, className, layers }, index) => ({
      label,
      value,
      className,
      layers,
{'fraction_non_alphanumeric': 0.13749114103472715, 'fraction_numerical': 0.002834868887313962, 'mean_word_length': 4.7145748987854255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '234302', 'n_tokens_mistral': 837, 'n_tokens_neox': 829, 'n_words': 237}