static/js/miniplot.js
/**
 * Initialize mini plot controls.
 * @function initMiniPlotCtrl
 * @param {Object} mo - main object
 */
Initialize mini plot controls.
@function initMiniPlotCtrl
@param {Object} mo - main object
Initialize mini plot controls . @function initMiniPlotCtrl @param { Object } mo - main object
function initMiniPlotCtrl(mo) {
  let cav = byId('mini-canvas');
  cav.height = cav.width * 0.5625;
  mo.mini.canvas = cav;
  cav.addEventListener('mousedown', function (e) {
    const rect = this.getBoundingClientRect();
    mo.mini.drag = (e.clientX - rect.left) / (rect.right - rect.left) *
      cav.width;
  });
  cav.addEventListener('mousemove', function (e) {
    miniPlotMouseMove(e, mo);
  });
  cav.addEventListener('mouseup', function () {
    byId('legend-tip').classList.add('hidden');
    if (mo.mini.drag !== null) miniPlotSelect(mo);
  });
  cav.addEventListener('mouseleave', function () {
    if (mo.mini.bin0 !== null) {
      mo.mini.bin0 = null;
      mo.mini.bin1 = null;
      updateMiniPlot(mo);
      byId('legend-tip').classList.add('hidden');
    }
  });
  byId('mini-field-sel').addEventListener('change', function () {
    mo.mini.field = (this.value === '') ? null : this.value;
    updateMiniPlot(mo);
  });
  byId('mini-log-btn').addEventListener('click', function () {
    this.classList.toggle('pressed');
    mo.mini.log = this.classList.contains('pressed');
    updateMiniPlot(mo);
  });
  byId('mini-plus-btn').addEventListener('click', function () {
    if (mo.mini.nbin < 50) {
      mo.mini.nbin++;
      updateMiniPlot(mo);
    }
  });
  byId('mini-minus-btn').addEventListener('click', function () {
    if (mo.mini.nbin > 0) {
      mo.mini.nbin--;
      updateMiniPlot(mo);
    }
  });
}
function initMiniPlotCtrl ( mo ) { let cav = byId ( 'mini-canvas' ) ; cav . height = cav . width * 0.5625 ; mo . mini . canvas = cav ; cav . addEventListener ( 'mousedown' , function ( e ) { const rect = this . getBoundingClientRect ( ) ; mo . mini . drag = ( e . clientX - rect . left ) / ( rect . right - rect . left ) * cav . width ; } ) ; cav . addEventListener ( 'mousemove' , function ( e ) { miniPlotMouseMove ( e , mo ) ; } ) ; cav . addEventListener ( 'mouseup' , function ( ) { byId ( 'legend-tip' ) . classList . add ( 'hidden' ) ; if ( mo . mini . drag !== null ) miniPlotSelect ( mo ) ; } ) ; cav . addEventListener ( 'mouseleave' , function ( ) { if ( mo . mini . bin0 !== null ) { mo . mini . bin0 = null ; mo . mini . bin1 = null ; updateMiniPlot ( mo ) ; byId ( 'legend-tip' ) . classList . add ( 'hidden' ) ; } } ) ; byId ( 'mini-field-sel' ) . addEventListener ( 'change' , function ( ) { mo . mini . field = ( this . value === '' ) ? null : this . value ; updateMiniPlot ( mo ) ; } ) ; byId ( 'mini-log-btn' ) . addEventListener ( 'click' , function ( ) { this . classList . toggle ( 'pressed' ) ; mo . mini . log = this . classList . contains ( 'pressed' ) ; updateMiniPlot ( mo ) ; } ) ; byId ( 'mini-plus-btn' ) . addEventListener ( 'click' , function ( ) { if ( mo . mini . nbin < 50 ) { mo . mini . nbin ++ ; updateMiniPlot ( mo ) ; } } ) ; byId ( 'mini-minus-btn' ) . addEventListener ( 'click' , function ( ) { if ( mo . mini . nbin > 0 ) { mo . mini . nbin -- ; updateMiniPlot ( mo ) ; } } ) ; }
Initialize mini plot controls.
Initialize mini plot controls .
// mini plot aspect: 16:9 // store in main object // mouse down event // identify and store position of mouse in plot // mouse move event // mouse up event // trigger selection if mouse was dragging // mouse leave event // plot selected variable // log-transform variable // increase resolution // decrease resolution