{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Levels Of Detail\n", "\n", "Although the interactivity and high resolution you get from BeakerX’s charting library are a feature, creating DOM elements for every single data point is memory and CPU intensive. If implemented simply, your web browser would become sluggish or freeze if you tried to chart too much data. Fortunately, Beaker recognizes this situation and has a solution: Levels of Detail. If there are more than 1500 points, then instead of drawing them all, Beaker combines points into groups, and represents each group with its average, a box, or a river (min, max, and average).\n", "\n", "And then, as you zoom into the data, it is resampled as appropriate for the current view, so the closer you look, the more there is to see, but you can still pull out and get the big picture while keeping the frame rate high.\n", "\n", "Note that BeakerX’s Level of Detail feature can’t protect you if your dataset set itself is too large to fit in your web browser (see [#6197](https://github.com/twosigma/beakerx/issues/6197)). In that case, you should use a plotting library that renders to a PNG image like matplotlib in Python, or do the resampling on the server manually." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// generate a random walk\n", "steps = 10000\n", "random = new Random()\n", "def walk(ssize) {\n", " def cur = 0.0\n", " def x = []\n", " def y = []\n", " for (i in 0..steps) {\n", " y[i] = cur\n", " x[i] = i\n", " cur += random.nextGaussian() * ssize\n", " }\n", " return [x:x, y:y]\n", "}\n", "// now x is time for the x-axis, and y is the random variable\n", "beer = walk(10)\n", "whiskey = walk(100)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "p = new TimePlot(title: \"Drunken Sailor Walks\", showLegend: true, lodThreshold: 2000)\n", "p << new Line(x:beer.x, y:beer.y, displayName:\"Beer Walk\")\n", "p << new Line(x:whiskey.x, y:whiskey.y, displayName:\"Whiskey Walk\")" ] } ], "metadata": { "anaconda-cloud": {}, "beakerx_kernel_parameters": {}, "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" } }, "nbformat": 4, "nbformat_minor": 1 }