JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector drawing.

Overview

JustGage

Downloads

Build

PRs Welcome MIT Licence

NPM

JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector drawing.

Getting Started

Installing Justgage is as easy as...

bower install justgage-official

or maybe you wish to use NPM...

npm install justgage --save

or you can always download the CSS and JS files...

<!-- Raphael must be included before justgage -->
<script type="text/javascript" src="path/to/raphael.min.js"></script>
<script type="text/javascript" src="path/to/justgage.js"></script>

or if even don't want to download the files use cdnjs

<!-- Raphael must be included before justgage -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/justgage/1.2.9/justgage.min.js"></script>

Basic usage

Html

<div id="gauge"></div>

JS

var gauge = new JustGage({
            id: "gauge", // the id of the html element
            value: 50,
            min: 0,
            max: 100,
            decimals: 2,
            gaugeWidthScale: 0.6
        });

// update the value randomly
setInterval(() => {
  gauge.refresh(Math.random() * 100);
}, 5000)

Options

Name Default Description
id (required) The HTML container element id
value 0 Value Gauge is showing
parentNode null The HTML container element object. Used if id is not present
defaults false Defaults parameters to use globally for gauge objects
width null The Gauge width in pixels (Integer)
height null The Gauge height in pixels
valueFontColor #010101 Color of label showing current value
valueFontFamily Arial Font of label showing current value
symbol '' Special symbol to show next to value
min 0 Min value
minTxt false Min value text, overrides min if specified
max 100 Max value
maxTxt false Max value text, overrides max if specified
reverse false Reverse min and max
humanFriendlyDecimal 0 Number of decimal places for our human friendly number to contain
textRenderer null Function applied before redering text (value) => value return false to format value based on config options
onAnimationEnd null Function applied after animation is done
gaugeWidthScale 1.0 Width of the gauge element
gaugeColor #edebeb Background color of gauge element
label '' Text to show below value
labelFontColor #b3b3b3 Color of label showing label under value
shadowOpacity 0.2 Shadow opacity 0 ~ 1
shadowSize 5 Inner shadow size
shadowVerticalOffset 3 How much shadow is offset from top
levelColors ["#a9d70b", "#f9c802", "#ff0000"] Colors of indicator, from lower to upper, in RGB format
startAnimationTime 700 Length of initial animation in milliseconds
startAnimationType > Type of initial animation (linear, >, <, <>, bounce)
refreshAnimationTime 700 Length of refresh animation in milliseconds
refreshAnimationType > Type of refresh animation (linear, >, <, <>, bounce)
donutStartAngle 90 Angle to start from when in donut mode
valueMinFontSize 16 Absolute minimum font size for the value label
labelMinFontSize 10 Absolute minimum font size for the label
minLabelMinFontSize 10 Absolute minimum font size for the min label
maxLabelMinFontSize 10 Absolute minimum font size for the man label
hideValue false Hide value text
hideMinMax false Hide min/max text
showInnerShadow false Show inner shadow
humanFriendly false convert large numbers for min, max, value to human friendly (e.g. 1234567 -> 1.23M)
noGradient false Whether to use gradual color change for value, or sector-based
donut false Show donut gauge
relativeGaugeSize false Whether gauge size should follow changes in container element size
counter false Animate text value number change
decimals 0 Number of digits after floating point
customSectors {} Custom sectors colors. Expects an object
formatNumber false Formats numbers with commas where appropriate
pointer false Show value pointer
pointerOptions {} Pointer options. Expects an object
displayRemaining false Replace display number with the value remaining to reach max value

Custom Sectors

Example:

customSectors: {
  percents: true, // lo and hi values are in %
  ranges: [{
    color : "#43bf58",
    lo : 0,
    hi : 50
  },
  {
    color : "#ff3b30",
    lo : 51,
    hi : 100
  }]
}

Pointer options

Example:

pointerOptions: {
  toplength: null,
  bottomlength: null,
  bottomwidth: null,
  stroke: 'none',
  stroke_width: 0,
  stroke_linecap: 'square',
  color: '#000000'
}

Methods

Refresh

Used to refresh Gauge value and max value

guage.refresh(val, max, min, label)

  • val : The Gauge value (required)
  • max : The Gauge Max value (optional)
  • min : The Gauge Min value (optional)
  • label : The Gauge label text (optional)

Update

Used to dynamically update existing Gauge appearence

gauge.update(option, value)

vs

const options = {
  valueFontColor: '#ff0000',
  labelFontColor: '#ff0000',
}
gauge.update(options)

Update Options

Name Description
valueFontColor HEX color for gauge value text
labelFontColor HEX color for gauge min, max and label text

Destroy

Used to destroy the Gauge element

guage.destroy()

Demo

Click here to see a demo

Examples

Click here for a list of examples

Changelog

Check out the auto-generated Changelog

Or here you can find the old changelog (up to version 1.2.9)

BREAKING CHANGES

  • 1.2.9
    • customSectors expects an object and not an array (percent support, check docs for more info)
  • 1.2.6
    • Removed title feature

License

This project is licensed under MIT License

Author

Comments
  • Further control over labels, colours,fonts and adornments

    Further control over labels, colours,fonts and adornments

    :)

    Could I have more control over what is displayed in the UI?

    I would love to be able to set or remove each label/string. Having just the vector arc is a very attractive prospect.

    Setting the colour of each label/string is also a big want.

    Setting an adornment for each string is also attractive (might be a "%" or a "$", eg 76% or $99 or 173°)

    I'll keep on thinking!

    enhancement 
    opened by brendanheyu 22
  • access min value programmatically

    access min value programmatically

    Is it possible to change the scale minimum value like the max value (gg1.refresh(gg1.originalValue, 10) ? If not, it would be a nice additional feature.

    opened by NSchnitzler 20
  • Gauges don't respond to window resize in fluid layouts

    Gauges don't respond to window resize in fluid layouts

    In fluid layouts, everything updates when the window is resized, maximized, etc - but the gauges don't adjust. I might be blanking on something that should be handled in the layout itself, but I really can't think of anything.

    Using fluid layout in Bootstrap.

    opened by erquhart 17
  • Enhancement: ability to add a target value, thresholds

    Enhancement: ability to add a target value, thresholds

    Great job with this, really nice. I'm interested in using this to display real time (or near real time) metrics. For us, I think being able to set and visualise a target value that we want to hit, or a threshold that we need to stay inside would be really cool. Plus as an aside, being able to alert on leaving that threshold so that we can act on it.

    I've forked the repo but if you have any ideas on this it'd be great to hear them. Will let you know I get on.

    enhancement 
    opened by Ianfeather 16
  • corrupted file http://justgage.com/justgage-1.2.2.zip

    corrupted file http://justgage.com/justgage-1.2.2.zip

    I think the zip (http://justgage.com/justgage-1.2.2.zip) on the main page http://justgage.com/ is corrupted. Both js at the root of the zip seems to be empty

    opened by danielsawan 14
  • uncaught TypeError: Object has no method 'toFixed' when using refreshmax

    uncaught TypeError: Object has no method 'toFixed' when using refreshmax

    I'm seeing this error crop up when I use the .refresh method: http://prntscr.com/x0kuo

    Any ideas? I could be doing something very wrong on my end.

    Thanks,

    -James

    opened by jgentes 13
  • justgage used in layouts without a initial fixed size

    justgage used in layouts without a initial fixed size

    Love your work!

    When using justgage in a layout that is built in a responsive fashion (http://twitter.github.com/bootstrap/ etc) you inevitably have to place the gauges themselves in divs of no specific size. A responsive layout dictates that the layout will change depending on the platform/device/orientation/screen width - so the div size might be set with a grid layout that calculates a percentage.

    Can this be achieved? Can justgage render a chart to a div that has it size calculated as opposed to specifically set?

    FF 14, IE9 and Opera 12 are all happy to render an initial gauge that works - however there is no recalculating of the gauge size on resize. Chrome and Safari both have a mental breakdown and render vectors all about the place :)

    Older IE's don't seem to render at all. This was just the result of a quick test.

    enhancement 
    opened by brendanheyu 12
  • Adding + sign when value is positive

    Adding + sign when value is positive

    Hello folks, Is there any way a '+' sign could be added in front of a positive value ?

    If I graph from -100 to 100, and choose let's say -27, the minus sign is displayed. But if I want to show a trend, like +26%, I can only get 26% displayed.

    Any hint ?

    opened by thierry-dosseto 11
  • Long term refresh & memory leak

    Long term refresh & memory leak

    Hi all,

    i'm using several justgages on a monitoring page, with justgages updated every second via the .refresh function.

    If i keep the page open in Chrome for a few hours, the page crashes with out of memory. If i remove the gages there's no error. I did a profile in chrome and at least, for a few minutes of usage, there's no leak.

    Any suggestions ?

    opened by synologic 10
  • Invalid value for <path> attribute d=

    Invalid value for attribute d="Z"

    I have this function:

    function drawIt() { var g = new JustGage({ id: "tempgauge", value: 67, min: 0, max: 100, title: "Visitors" }); }

    If I call it inside script tags, everything works great.

    If I call it via body onload="drawIt()", then I get these errors, because jQuery is hiding the gauge.

    Error: Invalid value for attribute d="Z" raphael.2.1.0.min.js:10 q raphael.2.1.0.min.js:10 w raphael.2.1.0.min.js:10 A.attr raphael.2.1.0.min.js:10 JustGage justgage.1.0.1.min.js:12 drawIt alfred.js:34 onload alfred.html:59

    Is there a way to draw a gauge that isn't currently visible?

    opened by AlfredTheJeep 10
  • Problem Color with CustomSectors

    Problem Color with CustomSectors

    When I define a "color" on the range of customSectors, nothing change, the color default stay

    maybe I forgot an option ?

    examples/custom-sectors.html

    opened by mxgr59 9
Releases(v1.6.1)
Owner
Bojan Djuricic
Bojan Djuricic
A Simple jQuery Plugin for Animating Scroll

AnimateScroll A Simple jQuery Plugin for Animating the Scroll Demo can be seen at http://plugins.compzets.com/animatescroll What is it exactly? Animat

Ram 714 Jul 21, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Personal project to a student schedule classes according his course level. Using GraphQL, Clean Code e Clean Architecture.

classes-scheduler-graphql This is a personal project for student scheduling, with classes according his course level. I intend to make just the backen

Giovanny Lucas 6 Jul 9, 2022
Small PNG to WEBP converter, terminal based and handy for a frontend developer :D

Image Utils A small util i used while making antstack.com What does it do and how to use? It basically converts .png files to .webp Read about Webp he

Pruthvi Shetty 6 Aug 24, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Dashboard skeleton Simple and fast dashboard skeleton template

Dashboard skeleton Simple and fast dashboard skeleton template. Installation npm install --save dashboard-skeleton-compostrap Version 1x built on Boo

Compostrap 9 Aug 23, 2022
This is a jquery ui sortable helper plugin for handy tree type structure sotable.

Tree Sortable A drag and drop list item sorting and level changing library. Motivation The jQuery-ui's sortable plugin allows us to sort items vertica

Sajeeb Ahamed 10 Dec 23, 2022
JavaScript library to make drawing animation on SVG

vivus.js Demo available on http://maxwellito.github.io/vivus Play with it on Vivus Instant Vivus is a lightweight JavaScript class (with no dependenci

maxwellito 14.5k Jan 3, 2023
nice-dag is a lightweight javascript library, which is used to present a DAG diagram.

Nice-DAG Overview Nice-DAG is a lightweight javascript library, which is used to present a DAG diagram. Essentially, it uses dagre to layout nodes and

eBay 11 Oct 25, 2022
A JavaScript library for drawing network graphs.

Gnet.js Gnet is a JavaScript library for network graph visualization, developed by Goutham. First I want to thank D3.js developers for creating such a

Goutham S 1 May 9, 2021
This app helps manage a bookstore. It comes in handy when you need to manage a personal book store or library. Entirely built on es6.

Awesome Books A Microverse project on learnong javascript. Additional description about the project and its features. Built With HTML5 CSS3 Javascript

Atugonza ( Billions ) Joel 13 Apr 22, 2022
Cross provider map drawing library, supporting Mapbox, Google Maps and Leaflet out the box

Terra Draw Frictionless map drawing across mapping providers. TerraDraw centralises map drawing logic and provides a host of out the box drawing modes

James Milner 106 Dec 31, 2022
The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day today activies. Check out the live demo.

Todo List App The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day toda

Atugonza ( Billions ) Joel 14 Apr 22, 2022
Adds a handy $parent magic property to your Alpine components.

✨ Help support the maintenance of this package by sponsoring me. Alpine $parent Access parent components using a handy $parent magic variable. This pa

Ryan Chandler 10 Aug 29, 2022
A handy wrapper for the Web Notifications API

Notify.js A handy wrapper for using the Web Notifications API. Notify.js aims to simplify requesting user permission and associated Web Notification A

Alex Gibson 1.3k Dec 4, 2022
A handy-dandy JS shim to run OreUI files in your browser (to varying degrees of success.)

OreUIShim (C) Luminoso 2022 / MIT Licensed. Contributions Welcome! A small shim JS file to experiment with oreUI in the browser. How to use Prerequisi

null 12 Dec 8, 2022
A handy little app for copying & pasting images.

PikPicPASTE A handy little app for copying & pasting images. Usage Click and drag the hamburger tile to move the toolbar Click the hamburger tile to s

null 5 Nov 1, 2022