<commit_before>Polymer({
  is: 'radar-chart',
  properties: {
    title: '',
    inputs: {
      notify: true,
      type: Array,
      value: [{
        input: 'x',
        txt: 'Pick a dimension',
        selectedValue: null,
        selectedObjs: [],
        selectedName: 'label',
        uitype: 'single-value',
        displayName: 'Diamension',
        maxSelectableValues: 1
      }, {
        input: 'y',
        txt: 'Pick a mesaure',
        selectedValue: null,
        selectedObjs: [],
        selectedName: 'count',
        uitype: 'single-value',
        displayName: 'Value',
        maxSelectableValues: 2
      }, {
        input: 'z',
        txt: 'Group By',
        selectedValue: null,
        selectedObjs: [],
        selectedName: 'count',
        uitype: 'single-value',
        displayName: 'Group By',
        maxSelectableValues: 1
      }]
    },
    hideSettings: true,
    source: {
      type: Array,
      value: []
    },
    external: Array,
    svg: Object,
    settings: {
      notify: true,
      type: Object,
      value: () => {
        return [];
      }
    }
  },

  behaviors: [
    PolymerD3.chartBehavior
  ],

  _toggleView: function() {
    this.hideSettings = !this.hideSettings;
  },

  init: function() {
    this.data = this.loadFromGroup(this.yIndex);
  },

  loadFromMultiCol: function(yIndices) {
    let headers = this.source[0];
    let data = [];
    for(let i = 1; i < this.source.length; i++){
      let data1 = [];
      for(let j = 0; j <yIndices.length; j++){
        let tA= [];
        tA.push(headers[yIndices[j]]);
        tA.push(this.source[i][j]);
        tA.push(this.source[i][this.xIndex]);
        data1.push(tA);
      }
      data.push(data1);
    }
    return data;
  },

  loadFromGroup: function(yIndices) {
    let layers = d3.nest()
      .key(d => d[this.zIndex])
      .entries(this.source);

    let data  = [];

    layers.forEach((element)=>{
      let data1 = [];
      element.values.forEach(value => {
        data1.push([value[this.xIndex],value[yIndices[0]], value[this.zIndex]]);
      });
      data.push(data1);
    });

    return data;
  },

  draw: function() {
    this.debounce('radarDrawDebounce', () => {
      this.xIndex = this.getInputsProperty('x');
      this.yIndex = this.getInputsProperty('y');
      this.zIndex = this.getInputsProperty('z');

      if(this.xIndex == null || this.yIndex == null || this.zIndex == null) {
        return false;
      }

      this.init();
      this.parentG.html('');
      let color = d3.scale.ordinal()
        .range(['#EDC951','#CC333F','#00A0B0']);

      let radarChartOptions = {
        w: this.chartWidth,
        h: this.chartHeight,<commit_msg>Fix console error in radar chart<commit_after>Polymer({
  is: 'radar-chart',
  properties: {
    title: '',
    inputs: {
      notify: true,
      type: Array,
      value: [{
        input: 'x',
        txt: 'Pick a dimension',
        selectedValue: [],
        selectedObjs: [],
        selectedName: 'label',
        uitype: 'single-value',
        displayName: 'Diamension',
        maxSelectableValues: 1
      }, {
        input: 'y',
        txt: 'Pick a mesaure',
        selectedValue: [],
        selectedObjs: [],
        selectedName: 'count',
        uitype: 'single-value',
        displayName: 'Value',
        maxSelectableValues: 2
      }, {
        input: 'z',
        txt: 'Group By',
        selectedValue: [],
        selectedObjs: [],
        selectedName: 'count',
        uitype: 'single-value',
        displayName: 'Group By',
        maxSelectableValues: 1
      }]
    },
    hideSettings: true,
    source: {
      type: Array,
      value: []
    },
    external: Array,
    svg: Object,
    settings: {
      notify: true,
      type: Object,
      value: () => {
        return [];
      }
    }
  },

  behaviors: [
    PolymerD3.chartBehavior
  ],

  _toggleView: function() {
    this.hideSettings = !this.hideSettings;
  },

  // init: function() {
  //   debugger;
  //   this.data = this.loadFromGroup(this.yIndex);
  // },

  loadFromMultiCol: function(yIndices) {
    let headers = this.source[0];
    let data = [];
    for(let i = 1; i < this.source.length; i++){
      let data1 = [];
      for(let j = 0; j <yIndices.length; j++){
        let tA= [];
        tA.push(headers[yIndices[j]]);
        tA.push(this.source[i][j]);
        tA.push(this.source[i][this.xIndex]);
        data1.push(tA);
      }
      data.push(data1);
    }
    return data;
  },

  loadFromGroup: function(yIndices) {
    let layers = d3.nest()
      .key(d => d[this.zIndex])
      .entries(this.source);

    let data  = [];

    layers.forEach((element)=>{
      let data1 = [];
      element.values.forEach(value => {
        data1.push([value[this.xIndex],value[yIndices[0]], value[this.zIndex]]);
      });
      data.push(data1);
    });

    return data;
  },

  draw: function() {
    this.debounce('radarDrawDebounce', () => {
      this.xIndex = this.getInputsProperty('x');
      this.yIndex = this.getInputsProperty('y');
      try {
        this.zIndex = this.getInputsProperty('z');
      } catch (e) {
        console.warn(e)
      }

      if(this.xIndex == null || this.yIndex == null || this.zIndex == null) {
        return false;
      }

      this.init();
      this.parentG.html('');
      let color = d3.scale.ordinal()
        .range(['#EDC951','#CC333F','#00A0B0']);

      let radarChartOptions = {
        w: this.chartWidth,
        h: this.chartHeight,
{'fraction_non_alphanumeric': 0.16191686331457614, 'fraction_numerical': 0.00943909965510982, 'mean_word_length': 1.9783783783783784, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '3278132', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1814, 'n_words': 340}