<commit_before>/**
 * @jsx React.DOM
 */

var _ = require('lodash');
var React = require('react');
var classNames = require('classnames');
var Select = require('../../common/select.js');
var Notice = require('../../common/notice.js');
var Chart = require('./chart.js');
var CodeSample = require('./code_sample.js');
var AppDispatcher = require('../../../dispatcher/AppDispatcher');
var ExplorerConstants = require('../../../constants/ExplorerConstants');
var ExplorerActions = require('../../../actions/ExplorerActions');
var ExplorerStore = require('../../../stores/ExplorerStore');
var NoticeActions = require('../../../actions/NoticeActions');
var ExplorerUtils = require('../../../utils/ExplorerUtils');
var FormatUtils = require('../../../utils/FormatUtils');

var Visualization = React.createClass({

  noticeClosed: function() {
    NoticeActions.clearAll();
  },

  changeChartType: function(event) {
    var chartType = _.find(this.formatChartTypes(), function(type){
      return type.value === event.target.value;
    });
    var updates = {
      metadata: {
        visualization: { chartType: chartType.value }
      }
    };
    ExplorerActions.update(this.props.model.id, updates);
  },

  formatChartTypes: function() {
    return _.map(ExplorerUtils.getChartTypeOptions(this.props.model.query), function(type) {
      return {
        name: (type !== 'JSON') ? FormatUtils.toTitleCase(type).replace('chart', '') : type,
        value: type
      };
    });
  },

  chartType: function() {
    if (this.props.model.metadata.visualization &&
        this.props.model.metadata.visualization.chart_type) {
      return this.props.model.metadata.visualization.chart_type;
    }
    else {
      return _.first(ExplorerUtils.getChartTypeOptions(this.props.model.query))
    }
  },
<commit_msg>Using correct property name.<commit_after>/**
 * @jsx React.DOM
 */

var _ = require('lodash');
var React = require('react');
var classNames = require('classnames');
var Select = require('../../common/select.js');
var Notice = require('../../common/notice.js');
var Chart = require('./chart.js');
var CodeSample = require('./code_sample.js');
var AppDispatcher = require('../../../dispatcher/AppDispatcher');
var ExplorerConstants = require('../../../constants/ExplorerConstants');
var ExplorerActions = require('../../../actions/ExplorerActions');
var ExplorerStore = require('../../../stores/ExplorerStore');
var NoticeActions = require('../../../actions/NoticeActions');
var ExplorerUtils = require('../../../utils/ExplorerUtils');
var FormatUtils = require('../../../utils/FormatUtils');

var Visualization = React.createClass({

  noticeClosed: function() {
    NoticeActions.clearAll();
  },

  changeChartType: function(event) {
    var chartType = _.find(this.formatChartTypes(), function(type){
      return type.value === event.target.value;
    });
    var updates = {
      metadata: {
        visualization: { chart_type: chartType.value }
      }
    };
    ExplorerActions.update(this.props.model.id, updates);
  },

  formatChartTypes: function() {
    return _.map(ExplorerUtils.getChartTypeOptions(this.props.model.query), function(type) {
      return {
        name: (type !== 'JSON') ? FormatUtils.toTitleCase(type).replace('chart', '') : type,
        value: type
      };
    });
  },

  chartType: function() {
    if (this.props.model.metadata.visualization &&
        this.props.model.metadata.visualization.chart_type) {
      return this.props.model.metadata.visualization.chart_type;
    }
    else {
      return _.first(ExplorerUtils.getChartTypeOptions(this.props.model.query))
    }
  },

{'fraction_non_alphanumeric': 0.1833976833976834, 'fraction_numerical': 0.0, 'mean_word_length': 3.3127229488703924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4260851', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1020, 'n_words': 183}