Fork me on GitHub
jsGraph

Peak picking (discrete)

Use the peakPicking serie parameter (for serie line) to enable a basic peak picking algorithm. For a discrete serie (with the parameter lineToZero: true), the library will treat every data point as potential peak.

The option autoPeakPickingNb (default: 4) is the maximum number of peaks to be selected. The library will select the highest from the whole set.

Use autoPeakPickingMinDistance (default: 10) to set the minimal distance (in px) between two neighbouring peaks.

Source code

var graphinstance = new Graph( domGraph, {

  dblclick: {
    type: 'plugin',
    plugin: 'zoom',
    options: {
      mode: 'total'
    }
  },

  plugins: {
    'zoom': {
      zoomMode: 'x'
    }
  },

  pluginAction: {
    'zoom': {
      shift: false
    }
  },

  wheel: {
    type: 'plugin',
    plugin: 'zoom',
    options: {
      direction: 'y'
    }
  }

} );
graphinstance.newSerie( "msdata", {
  autoPeakPicking: true,
  autoPeakPickingNb: 10,
  autoPeakPickingFormat: function( val, index ) {
    this.prop( 'labelColor', ( index == 1 ? 'red' : 'blue' ) );
    return val.toFixed( 1 );
  },
  autoPeakPickingAllowAllY: true,
  lineToZero: true

}, 'line' )
  .autoAxis()
  .setData( serieData )
  .XIsMonotoneous();

graphinstance.redraw();
graphinstance.drawSeries();