How to use the dygraphs.prototype 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 / CustomDygraph.js View on Github external
*
 * @param {Element} element - param for Dygraph constructor
 * @param {Array} data - param for Dygraph constructor
 * @param {Object} options - param for Dygraph constructor
 * @param {Function} yAxisRangeCalculate - takes a dygraph
 *                                         returns a [min, max] y axis range
 */
function CustomDygraph(element, data, options, yAxisRangeCalculate) {
  // This code uses prototype syntax rather than class syntax because it needs
  // to set `this.yAxisRangeCalculate_` before calling the Dygraph constructor,
  // which isn't possible with class syntax.
  this.yAxisRangeCalculate_ = yAxisRangeCalculate;
  Dygraph.call(this, element, data, options);
}

CustomDygraph.prototype = Object.create(Dygraph.prototype);
CustomDygraph.prototype.drawGraph_ = function () {
  let yExtentAdjusted = this.yAxisRangeCalculate_(this);

  // Change it directly. Using `updateOptions` won't work. If it causes a
  // redraw, there's a stack overflow. With blockRedraw=true, it doesn't update
  // the axes. Avoid using a valueRange in the options if you're using a
  // CustomDygraph.
  this.axes_[0].valueRange = yExtentAdjusted;
  this.axes_[0].computedValueRange = yExtentAdjusted;
  this.axes_[0].extremeRange = yExtentAdjusted.map(
    (v) => v - yExtentAdjusted[0]
  );

  Dygraph.prototype.drawGraph_.call(this);
};
github numenta / numenta-apps / unicorn / app / browser / lib / Dygraphs / CustomDygraph.js View on Github external
CustomDygraph.prototype.drawGraph_ = function () {
  let yExtentAdjusted = this.yAxisRangeCalculate_(this);

  // Change it directly. Using `updateOptions` won't work. If it causes a
  // redraw, there's a stack overflow. With blockRedraw=true, it doesn't update
  // the axes. Avoid using a valueRange in the options if you're using a
  // CustomDygraph.
  this.axes_[0].valueRange = yExtentAdjusted;
  this.axes_[0].computedValueRange = yExtentAdjusted;
  this.axes_[0].extremeRange = yExtentAdjusted.map(
    (v) => v - yExtentAdjusted[0]
  );

  Dygraph.prototype.drawGraph_.call(this);
};