TimeseriesVisualization constructor

TimeseriesVisualization(
  1. Timeseries _timeseries
)

Creates a visualization for a Timeseries.

Implementation

TimeseriesVisualization(this._timeseries) {
  _stats = _timeseries.computeStats();
  _canvas = CanvasElement();
  _screenWidth = window.screen.width;
  _canvas.width = _screenWidth;
  _canvas.height = (_kCanvasHeight * window.devicePixelRatio).round();
  _canvas.style
    ..width = '100%'
    ..height = '${_kCanvasHeight}px'
    ..outline = '1px solid green';
  _ctx = _canvas.context2D;

  // The amount of vertical space available on the chart. Because some
  // outliers can be huge they can dwarf all the useful values. So we
  // limit it to 1.5 x the biggest non-outlier.
  _maxValueChartRange = 1.5 *
      _stats.samples
          .where((AnnotatedSample sample) => !sample.isOutlier)
          .map<double>((AnnotatedSample sample) => sample.magnitude)
          .fold<double>(0, math.max);
}