How to Visualize Time Series Data With μPlot Chart Library

μPlot.js – Fast, memory-saving graphic library based on 2D Canvas for quickly mapping time series, lines, areas, and bar charts.

Time series data is a lightweight, interactive, scalable, high-performance chart library to visualize any time a sequence of knowledge factors listed in time order utilizing Canvas API.

Visualize Time Series Data With μPlot Chart Library Details

Post NameTime Series Data μplot
Author Nameleeoniya
CategoryChart & Graphs Plugins
Official PageClick Here
Official Websitegithub.com
Publish DateAugust 22, 2020
Last UpdateJuly 24, 2023
DownloadLink Below
LicenseMIT

Features

  • Multiple series w/toggle
  • Multiple y-axes, scales & grids
  • The temporal or numeric x-axis
  • Linear, uniform, or logarithmic scales
  • Line & Area styles (stroke, fill, width, dash)
  • Pluggable path renderers linear, spline, stepped, bars
  • Zoom with auto-rescale
  • Legend with live values
  • Support for IANA Time Zone Names & DST
  • Support for missing data
  • Cursor sync for multiple charts
  • Focus on the closest series
  • Data streaming (live update)
  • High / Low bands
  • A lean, consistent, and powerful API with hooks & plugins

Non-Features

In order to stay slim, fast, and focused, the following features will not be added:

  • There is no data analysis, aggregation, aggregation, or statistical processing – just do it in advance. For example https://simplestatistics.org/, https://www.papaparse.com/
  • No transitions or animations – it’s always pure distractions.
  • There is no collision avoidance for axis label labels, so manual tweaking of spacing metrics may be required if label customization greatly increases the default label width.
  • There is no built-in drag/pan because of the ambiguous native zoom/select behavior. However, this can be added externally via a plugin/hooks API: zoom-wheel, zoom-touch.

Must Read: Easy Interface Javascript Chart Library Based on D3.js | billboard.js

How to make use of it:

1. Download and import the μPlot library.

<link rel="stylesheet" href="uPlot.css">
<script src="uPlot.iife.min.js"></script>

2. Prepare the time collection data.

const data = [

      // x-values (Unix timestamps)
      [1566458800, 1566452560, 1566460860, 1538464460], 

      // data series 1  
      [0.54, 0.15, 3.27, 7.51],

      // data series 2
      [12.85, 13.21, 13.65, 14.01],

      // data series 3
      [0.52, 1.25, 0.75, 3.62]

];

3. The instance JS to initialize the μPlot Library.

let myChart = new uPlot({

    // width/height in pixels
    width: 960,
    height: 400,

    // chart title
    title: "My Chart",

    // unique chart ID
    id: "chart1",

    // additional CSS class(es)
    class: "my-chart",

    // determines how to present your data
    series: [
      {},
      {
        // initial toggled state (optional)
        show: true,
        spanGaps: false,
        // in-legend display
        label: "RAM",
        value: (self, rawValue) => "$" + rawValue.toFixed(2),
        // series style
        stroke: "red",
        width: 1,
        fill: "rgba(255, 0, 0, 0.3)",
        dash: [10, 5],
      }
    ],

    // customize the x, y axis
    axes: {
      y: [
        {
          scale: '%',
          values: (vals, space) => vals.map(v => +v.toFixed(1) + "%"),
        },
        {
          side: 3,
          scale: 'mb',
          values: (vals, space) => vals.map(v => +v.toFixed(2) + "MB"),
          grid: null,
        },
      ],
    }
}, data, document.body);

4. Default x-axis options.

scale: 'x',
space: 40,
height: 30,
side: 0,
class: "x-time",
incrs: timeIncrs,
values: (vals, space) => {
  let incr = vals[1] - vals[0];

  let stamp = (
    incr >= d ? fmtDate('{M}/{D}') :
    // {M}/{DD}/{YY} should only be prepended at 12a?   // {YY} only at year boundaries?
    incr >= h ? fmtDate('{M}/{DD}\n{h}{aa}') :
    incr >= m ? fmtDate('{M}/{DD}\n{h}:{mm}{aa}') :
    fmtDate('{M}/{DD}\n{h}:{mm}:{ss}{aa}')
  );

  return vals.map(val => stamp(new Date(val * 1e3)));
},
grid: {
  color: "#eee",
  width: 2
}

5. Default y-axis options.

scale: 'y',
space: 30,
width: 50,
side: 1,
class: "y-vals",
incrs: numIncrs,
values: (vals, space) => vals,
grid: {
  color: "#eee",
  width: 2
}

6. Default options for the time series data on the x-axis.

label: "Time",
scale: "x",
value: v => stamp(new Date(v * 1e3))

7. Default options for the time series data on the y-axis.

shown: true,
label: "Value",
scale: "y",
value: v => v

See Demo And Download

Visualize-Time-Series-Data-With-UPlot

Official Website(leeoniya): Click Here

This superior jQuery/javascript plugin is developed by leeoniya. For extra Advanced usage, please go to the official website.

Related Posts

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Leave a Reply

Your email address will not be published. Required fields are marked *