Minimal Multi-line Chart Library In Pure JS – picograph.js

Category: Chart & Graph , Javascript | November 21, 2022
Views Total:526 views
Official Page:Go to website
Last Update:November 21, 2022


Minimal Multi-line Chart Library In Pure JS – picograph.js


picograph.js is a tiny and standalone JavaScript library to dynamically renders a minimal, multi-line chart on an HTML canvas element.

Ideal for generating auto-updating time-series graphs such as performance monitors, traffic usage reports, and much more.

Works on most modern browsers that support HTML5 canvas API.

How to use it:

1. Insert the JavaScript picograph.js into the document and we’re ready to go.

<script src="picograph.js"></script>

2. Create an HTML canvas element for the graph.

<canvas id="graphDemo"></canvas>

3. Create a DIV container for legends/labels.

<div id="graphLabels"></div>

4. Plot your data to the line graph. Possible parameters:

  • canvasID: canvas ID
  • labels: a list/array of label names
  • unit: the unit for values
  • labelDivID: CSS id of label container
  • intervalSize: amount to shift the graph on update
  • maxVal: max value
  • minVal: max value
  • scalesteps: step size
  • vlines: show vertical lines
  • timestamps: Show timestamps.
  • vlinesFreq: Vertical lines and timestamps will be drawn every vlinesFreq*intervalSize. Increase this if the vertical lines are too crowded.
  • autoScaleMode: When 0, minVal and maxVal become absolutes. When 1, autoscale to fit peaks only. When 2, graph scaling continuously adjusts to fit visible data.
var demo = createGraph(canvasID, labels, unit, labelDivID, intervalSize, maxVal, minVal, vlines=false, timestamps=false, scalesteps=5, vlinesFreq = 1, autoScaleMode=1);

5. Update the line graph.

Graph.update(yval, labelID)

6. Switch between graphs.

Graph.switchGraph(previousGraph, newGraph)



  • Remove redundant factory function


  • Added switchGraph function


  • Refactor to use proper JS and simplify utility functions


  • Refactor update method


  • Added minimum value scaling


  • Added vlinesFreq parameter


  • Removed unnecessary padding


  • Added vertical lines and timestamps

You Might Be Interested In:

Leave a Reply