Socket
Socket
Sign inDemoInstall

hdr-histogram-widget

Package Overview
Dependencies
5
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hdr-histogram-widget

Plotter widget for HdrHistogram


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
1.83 MB
Created
Weekly downloads
 

Readme

Source

HdrHistogram Widget

The purpose of this JavaScript widget is to easily visualize latencies recorded with HdrHistogram. The widget does not depend on any dependencies except HdrHistogramJS and hence may be used on any website.

screenshot

This widget allows to plot histograms encoded to base64, whatever the HdrHistogram language/platform used (Java, JS, C#, Rust, Go...)

Usage

Passing data in a URL

If you are in a hurry, you can generate an URL containing the histogram(s) you want to plot as a base64 url encoded string(s). The URL should look like the one below:

`https://hdrhistogram.github.io/HdrHistogramWidget?unitText=${"ms"}&data.name=${"HISTFAAAA..."}&data.other_name=${"HISTFAAAA..."}`;

Here is a working example

Writing some code

This library is packaged as a UMD module, hence you can use it directly from JavaScript within a browser. To do so, you can simply include the bundle file from github's release page:

<script src="https://github.com/HdrHistogram/HdrHistogramWidget/releases/download/1.0.1/hdr-histogram-widget.umd.js"></script>

If you prefer using npm:

  npm i hdr-histogram-widget

Then you can use the HdrHistogramWidget class which provides a convenient static method display():

import HdrHistogramWidget from "hdr-histogram-widget"; // not needed with the umd package

HdrHistogramWidget.display("HISTFAAAATR42i1M...");

You need to provide a base64 encoded histogram to this display() method.

If you need to display several histograms, you need to provide an object as shown below:

HdrHistogramWidget.display({
  "Latencies for option1": "HISTFAAAATR42i1M...",
  "Latencies for option2": "HISTFAAAAXt42i1O...",
  "Latencies for option3": "HISTFAAAAXt42i1O...",
});

By default the graph is displayed within the body of the page and the unit is 'milliseconds'. If the default behavior does not fit your needs, you can use two optionnal parameters:

const data = {
  'Latencies for option1': 'HISTFAAAATR42i1M...',
  ...
}
HdrHistogramWidget.display(
  data,
  'nano seconds',                   // default is milliseconds
  document.getElementById("graph")  // default is document.body
);

FAQs

Last updated on 14 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc