jQuery addClass example

Change class name on click in jQuery

by cubicalmonkey

HTML

<div id="container"></div>

JavaScript

$(document).ready(function () {
var spec = { };
var data = [
  [646.25, -34.49],
  [646.367187, -21.16],
  [646.484374, -25.23],
  [646.601561, -19.29],
  [646.718748, -15.65],
  [646.835935, -17.5],
  [646.953122, -19.25],
  [647.070309, -26.86],
  [647.187496, -36.88],
  [647.304683, -20.06],
  [647.42187, -17.8],
  [647.539057, -22.84],
  [647.656244, -21.55],
  [647.773431, -18.23],
  [647.890618, -22.75],
  [648.007805, -25.52],
  [648.124992, -24.57],
  [648.242179, -24.26],
  [648.359366, -26.94],
  [648.476553, -20.16],
  [648.59374, -23.08],
  [648.710927, -28.17],
  [648.828114, -24.99],
  [648.945301, -20.66],
  [649.062488, -27.1],
  [649.179675, -26.61],
  [649.296862, -22.77],
  [649.414049, -18.29],
  [649.531236, -18.11],
  [649.648423, -25.42],
  [649.76561, -29.83],
  [649.882797, -29.96],
  [649.999984, -20.65],
  [650.117171, -16.7],
  [650.234358, -25.18],
  [650.351545, -28.57],
  [650.468732, -40.63],
  [650.585919, -24.74],
  [650.703106, -18.45],
  [650.820293, -21.79],
  [650.93748, -20.16],
  [651.054667, -28.2],
  [651.171854, -23.93],
  [651.289041, -20.04],
  [651.406228, -28.36],
  [651.523415, -24.71],
  [651.640602, -34.43],
  [651.757789, -27.42],
  [651.874976, -18.99],
  [651.992163, -22.48]
];


function buildGraph() {
  //this.showWhat  is my amp values and determins if I'm graphing live data = amplitudeValues or max hold data = peakHoldValues 
  if (spec.levelsGraph) {  
    console.log(JSON.stringify(this.showWhat));
    spec.levelsGraph.updateOptions({
      'file': this.showWhat
    });
  }
  if (spec.levels == undefined) {
    spec.levels = [];
    spec.levels.options = {
      title: "Spectrum Analysis",
      axisLabelFontSize: 10,
      gridLineColor: '#878787',
      axisLabelColor: '#878787',
      digitsAfterDecimal: 2,
      drawPoints: false,
      strokeWidth: 1,
      ylabel: '( Live Data: Power (dB) )',
      xlabel: 'Frequency in Mhz',
      axisLineColor: '#342480',
      labelsSeparateLines: true,
     ...