Pretty graphs for traces
Customizable graphs for traces.
var Graph = require'trace-graph'fs = require'fs';// data would be from traces.get(cycle, fn)// in the "traces" modulevar graph = data;// graph.barWidth(1);// graph.barSpacing(.5);// graph.barTip(1);// graph.max(graph.mean() + 100);// graph.max(3000);graphbarAlpha4;graphscale1 12;graphlabel'Image Uploads';graphcolor'request' '#b1daec';graphcolor'resize' '#8fcdec';graphcolor'save' '#4cb4ec';graphcolor's3' '#1a9dec';graphdraw;fswriteFileSync'out.png' graphcanvastoBuffer;console.log'saved out.png';
Initialize a new graph with the given
Clip the graph at a maximum of
ms. For example if a few traces
2000ms, and most are around
100ms you'll likely want to
150 or so to have a better view.
Scale the graph on the
y axis. For example if you have several hundred
thousand traces, representing them each as a single pixel on the x-axis will be
too large, you may want to try
.scale(.2, 1). Like-wise if the y-axis reaches
durations of several seconds, this equates to several thousands of pixels by default
unless a y-axis scale is applied such as
Set bar "tip" to
Set bar "width" to
Set bar "spacing" to
Set bar alpha to
color for probe
Draw the graph.
(The MIT License)
Copyright (c) 2012 LearnBoost <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.