How to use the dygraphs.Plugins function in dygraphs

To help you get started, we’ve selected a few dygraphs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github numenta / numenta-apps / unicorn / app / browser / lib / Dygraphs / Plugins.js View on Github external
// FOR A PARTICULAR PURPOSE. See the GNU Affero Public License for more details.
//
// You should have received a copy of the GNU Affero Public License along with
// this program. If not, see http://www.gnu.org/licenses.
//
// http://numenta.org/licenses/

import Dygraph from 'dygraphs';


/**
 * Override default pre-draw of Dygraphs RangeSelector background, so we can
 *  customize the styling (remove RangeSelector outline border).
 * @see node_modules/dygraphs/plugins/range-selector.js
 */
Dygraph.Plugins.RangeSelector.prototype.drawStaticLayer_ = function () {
  let margin = 0.5;
  let ctx = this.bgcanvas_ctx_;
  ctx.clearRect(0, 0, this.canvasRect_.w, this.canvasRect_.h);

  try {
    this.drawMiniPlot_();
  } catch (error) {
    throw new Error(error);
  }

  this.bgcanvas_ctx_.lineWidth = 1;
  ctx.strokeStyle = '#fff';
  ctx.beginPath();
  ctx.moveTo(margin, margin);
  ctx.lineTo(margin, this.canvasRect_.h-margin);
  ctx.lineTo(this.canvasRect_.w-margin, this.canvasRect_.h-margin);
github numenta / numenta-apps / unicorn / app / browser / lib / Dygraphs / Plugins.js View on Github external
this.bgcanvas_ctx_.lineWidth = 1;
  ctx.strokeStyle = '#fff';
  ctx.beginPath();
  ctx.moveTo(margin, margin);
  ctx.lineTo(margin, this.canvasRect_.h-margin);
  ctx.lineTo(this.canvasRect_.w-margin, this.canvasRect_.h-margin);
  ctx.lineTo(this.canvasRect_.w-margin, margin);
  ctx.stroke();
}

/**
 * Override default draw of Dygraphs RangeSelector handle, so we can customize
 *  the styling.
 * @see node_modules/dygraphs/plugins/range-selector.js
 */
Dygraph.Plugins.RangeSelector.prototype.drawInteractiveLayer_ = function () {
  let ctx = this.fgcanvas_ctx_;
  let margin = 1;
  let width = this.canvasRect_.w - margin;
  let height = this.canvasRect_.h - margin;
  let zoomHandleStatus = this.getZoomHandleStatus_();

  ctx.clearRect(0, 0, this.canvasRect_.w, this.canvasRect_.h);
  ctx.strokeWidth = 1;

  if (!zoomHandleStatus.isZoomed) {
    if (this.iePanOverlay_) {
      this.iePanOverlay_.style.display = 'none';
    }
  } else {
    let leftHandleCanvasPos = Math.max(margin,
          zoomHandleStatus.leftHandlePos - this.canvasRect_.x);