<commit_before>/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @fileoverview Controls the display of the charts on the page.
 */

/**
 * The ChartDisplay controls the display of the charts.
 * @constructor
 * @param {Object} api The Monitoring API object.
 */
var ChartDisplay = function(api) {
  /**
   * Values for the range selector.
   * @type {Array.<string>}
   */
  this.timespanValues = ['5m', '10m', '20m', '30m', '40m', '50m', '1h', '2h',
                         '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', '11h',
                         '12h', '1d', '2d', '3d', '4d', '5d', '6d', '1w',
                         '2w', '3w', '30d'];

  /**
   * The default timespan to select on page load.
   * @type {number}
   */
  this.defaultTimespanIndex = 6;

  /**
   * The Monitoring API object.
   * @type {Object}
   * @private
   */
  this.api_ = api;

  /**
   * A list of objects representing the visible charts, their data, and
   * their queries.
   * @type {Array.<Object>}
   * @private
   */
  this.charts_ = [];

  /**
   * List of default charts to display.
   * @type {Array.<string>}
   * @private
   */
  this.defaultCharts_ = [
      'compute.googleapis.com/instance/uptime',
      'compute.googleapis.com/instance/disk/read_ops_count',
      'compute.googleapis.com/instance/disk/write_ops_count',
      'compute.googleapis.com/instance/disk/read_latencies',
      'compute.googleapis.com/instance/disk/write_latencies',
      'compute.googleapis.com/instance/network/received_bytes_count',
      'compute.googleapis.com/instance/network/sent_bytes_count',
      'compute.googleapis.com/instance/cpu/usage_time',
      'compute.googleapis.com/firewall/dropped_packets_count'
  ];
};

/**
 * Add the chart based on the provided metric.
 * @param {Object} metric A single metric object returned from the
 *     metricDescriptors.list API endpoint.
 */
ChartDisplay.prototype.display = function(metric) {

  var chartNumber = this.charts_.length;

  // Create a container to hold all chart elements.
  var chartContainer = this.createChartContainer_(chartNumber);

  // Create a title for the chart.
  var chartTitle = this.createChartTitle_(metric.annotations.DESCRIPTION);
  $(chartContainer).append(chartTitle);

  // Create an error element in which to display errors.<commit_msg>Bug fix: changed chart title to remove non-existent annotations field<commit_after>/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @fileoverview Controls the display of the charts on the page.
 */

/**
 * The ChartDisplay controls the display of the charts.
 * @constructor
 * @param {Object} api The Monitoring API object.
 */
var ChartDisplay = function(api) {
  /**
   * Values for the range selector.
   * @type {Array.<string>}
   */
  this.timespanValues = ['5m', '10m', '20m', '30m', '40m', '50m', '1h', '2h',
                         '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', '11h',
                         '12h', '1d', '2d', '3d', '4d', '5d', '6d', '1w',
                         '2w', '3w', '30d'];

  /**
   * The default timespan to select on page load.
   * @type {number}
   */
  this.defaultTimespanIndex = 6;

  /**
   * The Monitoring API object.
   * @type {Object}
   * @private
   */
  this.api_ = api;

  /**
   * A list of objects representing the visible charts, their data, and
   * their queries.
   * @type {Array.<Object>}
   * @private
   */
  this.charts_ = [];

  /**
   * List of default charts to display.
   * @type {Array.<string>}
   * @private
   */
  this.defaultCharts_ = [
      'compute.googleapis.com/instance/uptime',
      'compute.googleapis.com/instance/disk/read_ops_count',
      'compute.googleapis.com/instance/disk/write_ops_count',
      'compute.googleapis.com/instance/disk/read_latencies',
      'compute.googleapis.com/instance/disk/write_latencies',
      'compute.googleapis.com/instance/network/received_bytes_count',
      'compute.googleapis.com/instance/network/sent_bytes_count',
      'compute.googleapis.com/instance/cpu/usage_time',
      'compute.googleapis.com/firewall/dropped_packets_count'
  ];
};

/**
 * Add the chart based on the provided metric.
 * @param {Object} metric A single metric object returned from the
 *     metricDescriptors.list API endpoint.
 */
ChartDisplay.prototype.display = function(metric) {

  var chartNumber = this.charts_.length;

  // Create a container to hold all chart elements.
  var chartContainer = this.createChartContainer_(chartNumber);

  // Create a title for the chart.
  var chartTitle = this.createChartTitle_(metric.description);
  $(chartContainer).append(chartTitle);

  // Create an error element in which to display errors.
{'fraction_non_alphanumeric': 0.1275017253278123, 'fraction_numerical': 0.015873015873015872, 'mean_word_length': 3.082394366197183, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5865453', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1708, 'n_words': 536}