Tiny and Simple Javascript Graphing Library

Tiny and Simple Javascript Graphing Library

picograph.js Simple and tiny graphing library for javascript.


Simple and tiny graphing library for javascript.

Download picograph.js


Demo Image

<!DOCTYPE html>
        <script src="picograph.js"></script>
    <body style="font-family: Lucida Console, Monaco, monospace;">


        <!-- Canvas for the graph -->
        <canvas id="graphDemo" 
            style="width: 900px; height:200px; border:2px solid #000000;">

        <!-- div for legends/labels -->
        <div id="graphLabels"></div>

            /* Create graph using picograph */
            var demograph = createGraph("graphDemo", 
                ["Random Y0", "Random Y1"], 
                "units", "graphLabels", 50, 10, 0, true, true);

            /* Update values every second */
            setInterval(updateEverySecond, 1000);

            function updateEverySecond() {
                /* Get new values */
                yrand0 = Math.random()*10;
                yrand1 = Math.random()*10;

                /* Update graph */
                demograph.update([yrand0, yrand1])



Download picograph.js

function createGraph(canvasID, labels, unit, labelDivID, intervalSize,
    maxVal, vlines=false, timestamps=false, scalesteps=5, vlinesFreq = 1)

Arguments :

  • canvasID : The id of <canvas> tag for the graph.
  • labels : List/array of string for label names.
  • unit : The unit for the values.
  • labelDivID: ID of the <div> tag to place graph labels/legend.
  • intervalSize: Amount of pixels to shift the graph on update.
  • maxVal: Approximate maximum value. Picograph can autoscale, this argument is only for initial value.
  • minVal: Approximate minimum value. Picograph can autoscale, this argument is only for initial value.
  • vlines: Show vertical lines.
  • timestamps: Show timestamps.
  • scalesteps: Number of scale lines to draw on the graph.
  • vlinesFreq: Vertical lines and timestamps will be drawn every vlinesFreq*intervalSize. Increase this if the vertical lines are too crowded.

Returns : Graph object.


Arguments :

  • values : Array of values to add to the graph.


Always use CSS or style to set height and width of the canvas. Do not use height and width attributes of the canvas tag, it may cause scaling issues.

Correct Way:

<canvas id="graphDemo" style="width: 900px; height:200px">

Or you can use CSS flex box, the canvas should be surrounded by

<div style="flex-basis: 0; flex-grow: 1;">

Incorrect Way:

<canvas id="graphDemo" width=900 height=200">

Download Details:

Author: RainingComputers

Source Code: https://github.com/RainingComputers/picograph.js


Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

JavaScript Shopping Cart - Javascript Project for Beginners

JavaScript Shopping Cart - javascript shopping cart tutorial for beginnersBuy me a coffee 🍺 https://www.paypal.com/paypalme/ziddahSource Code: https://bit....

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

Data Types In JavaScript

JavaScript data types are kept easy. While JavaScript data types are mostly similar to other programming languages; some of its data types can be unique. Here, we’ll outline the data types of JavaScript.

Introduction With Basic JavaScript

Introduction With Basic JavaScript - Unlike most programming languages, the JavaScript language has no concept of input or output. It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world.

JavaScript Memory Management System

The main goal of this article is help to readers to understand that how memory management system performs in JavaScript. I will use a shorthand such as GC which means Garbage Collection. When the browsers use Javascript, they need any memory location to store objects, functions, and all other things. Let’s deep in dive that how things going to work in GC.