Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

justgage

toorshia10.9kMIT1.7.0

JustGage is a handy JavaScript plugin for generating and animating nice & clean gauges. It is based on Raphaël library for vector drawing, so it’s completely resolution independent and self-adjusting.

gauge, meter, clean, simple, minimal, svg, vector, performance, indicator, measure, dashboard, javascript, plugin

readme

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
differential false Gauge will fill starting from the center, rather than from the min value
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
targetLine null Value Target line will display
targetLineColor "#000000" Color of Target Line
targetLineWidth 1.5 Width of Target Line

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'
}

TargetLine

Example:

var gauge = new JustGage({
            id: "gauge-targetLine", 
            value: 50,
            min: 0,
            max: 100,
            decimals: 2,
            gaugeWidthScale: 0.6,
            targetLine: 50,
            targetLineColour: "#000",
            targetLineWidth: 4
        });

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

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v1.6.1

  • fix: make differential work with all intervals ab0e50e

v1.6.0

1 December 2022

  • feat: differential gauge #380
  • chore: bump got and release-it #378
  • chore: bump parse-url from 6.0.0 to 6.0.5 #377
  • chore: bump minimist from 1.2.5 to 1.2.6 #369
  • chore: bump deps and fix example 7037f11
  • Release 1.6.0 0b5e9e9
  • chore: bump ci da56338

v1.5.1

10 December 2021

  • fix: dtyle conflict with multiple gauges created using the "parentNode" method #367
  • chore: bump path-parse from 1.0.6 to 1.0.7 #366
  • chore: add release-it a7f66e6
  • chore: add auto-changelog and fix audit ec9b25b
  • Release 1.5.1 efe8533

v1.5.0

11 June 2021

  • chore: setup eslint with workflow #364
  • Release 1.5.0 f55d4b7

v1.4.3

11 June 2021

  • feat: use custom formats when textRenderer returns false #363
  • chore: bump lodash from 4.17.19 to 4.17.21 #361
  • Release 1.4.3 7ab8342

v1.4.2

15 February 2021

  • fix: refresh with min/max 0 #360
  • fix: refresh with min/max 0 (#360) #359
  • Release 1.4.2 57b1ad4

v1.4.1

10 February 2021

  • feat: labelFontFamily #358
  • chore: bump ini from 1.3.5 to 1.3.7 #357
  • chore: bump lodash from 4.17.15 to 4.17.19 #353
  • Release 1.4.1 9052a03

v1.4.0

4 August 2020

  • chore: bump websocket-extensions from 0.1.3 to 0.1.4 #350
  • chore: Upgrade raphael from 2.2.8 to 2.3.0 #347
  • Release 1.4.0 fd67389
  • refactor: Cleaner code for pki e ndl custom functions d6308e3
  • fix: umd template b51eddd

v1.3.5

15 January 2020

  • from isHexNumber to isHexColor #343
  • from isHexNumber to isHexColor #1
  • Release 1.3.5 70df415
  • from ixHexNumber to isHexColor 105504c

v1.3.4

14 January 2020

  • Issue 241 - Support for refresh(options) where options will extend current options #340
  • Release 1.3.4 2d1ddf9
  • feat: Issue 241 - added update method to support updating valueFontColor hex value dynamically 3e0841b
  • feat: Issue 241 - added support for options as array in update() 4245021
  • docs: Issue-241 - update README to include .update() functionality a7cdb9f
  • feat: Issue 241 - add support for labelFontColor as update() parameter 11a6455
  • Update index.html 5fce6bc
  • docs: Updated Readme with breaking changes 76043c1
  • Release 1.3.4 8e22994
  • Update index.html ce6e872
  • fix: Removed const and backtick for browser compatibility 491a010
  • fix: Animation time human numbers example ac84e89
  • chore: Revert after failed release 3ac9d41
  • fix: Human numbers example range 59c0945
  • Update index.html c090293
  • Update index.html 251b7c4

v1.3.3

5 November 2019

  • README npm example link #337
  • Release 1.3.3 7e7a3c8
  • [fix] JustGage is not defined #338 90b66c6
  • docs: addition of link to sample repo that demonstrates npm/browserfy setup for justgage as a package 0a0d960
  • chore: added link url b0f997c

v1.3.2

9 October 2019

  • [docs] Fixed examples 585b0ff
  • [docs] Moved justgage.com in docs for github pages 38400c3
  • [docs] Added examples list to index 1143a1d
  • Release 1.3.2 04d4986
  • [fix] Cleaner events management d0af184
  • [docs] Added example with variable min max values 22a5915
  • [refactor] Cleaner code with isUndefined function 3ac69cf
  • [chore] Updated raphael and added map file to release 9e41515
  • [docs] Readme links and better list of examples names b364a1b
  • [docs] Fixed examples links and style 878bdc4
  • [fix] Moved level id to bindEvent function 0a68463
  • [fix] Bug when min is not 0 80960ca
  • [docs] Updated readme b438b11
  • [docs] Fixed regex replace for examples name abc1d40
  • [docs] Typo on readme 9de25b6
  • [docs] Fixed typo 1fa000f

v1.3.1

6 August 2019

  • add displayRemaining property #275
  • Update .refresh() to support min value #265
  • [feat] Made JustGage AMD andCommonJS friendly 8815ad8
  • [build] Dist files and updated release script 4b235eb
  • [docs] Display remaining example and docs 5af3d23
  • [fix] Reverse example customSectors 350a7db
  • [feat] Raphael 2.2.8 5debfd6
  • Release 1.3.1 d3615af
  • [fix] Destroy event and example 15f3c26
  • [feat] Gruntfile for dist b6cd2cb
  • [docs] Methods section d6d28cf
  • [feat] Support for label in refresh method 3eea1ac
  • [fix] Memory leak: Unbind events on destroy #296 e4993c0
  • [feat] Refresh with min value support (back compatible fix) b51840c
  • Fixed refresh and other locations for displayRemaining e78d035
  • Added a displayRemaining property which will show the difference between value and max (useful if you're more interested in how much is left, rather than how much has been used. 904654b
  • [refactor] Comments ca519ed
  • [fix] Eve not defined 81cff4c
  • [fix] Removed const 2d1773a
  • [docs] Added label to refresh 7d21cb9

v1.3.0

5 August 2019

  • Fix negative values handling #312
  • Made library commonJs friendly #256
  • Fix for negative numbers, humanFriendly and customSectors #326
  • [docs] Added changelog and updarted readme 85d13ef
  • [docs] Options c514faf
  • [build] Added gitignore and npmignore files c770b15
  • [docs] Updated readme b17651d
  • [docs] Fixed readme 8c29fe9
  • Release 1.3.0 0b920d4
  • Round Human friendly numbers less than 1000 83c8a93
  • [build] Added changelog and release scripts afee0b8
  • removed silly typho a1674e3
  • Fix custom sectors colors 10dc1f9
  • actually I needed those exports 1cf2444
  • justgauge.js now imports raphael and exports itself as a module 9455c88
  • [docs] Added GIF screenshot 35b69ad
  • Refactor and fix displayed value e236faa
  • export removed because it's now in index.js cb63f3f
  • Fix make function work with negative numbers too 66c48c5
  • Fix issue with negative bounds f7f1071
  • index.js to standarize commonjs module 5ab4013
  • added raphael as a dependency in package.json a702f09
  • [chore] Enabled npm publish on release-it ec2853f
  • [fix] Default pointerOptions value eae6844
  • [build] Fix raphael dependencies f71c4a2
  • [build] Fixed version in package.json f6b03b5
  • fixed route 7231c75
  • main: now references index.js d062a85
  • [build] Ignore changelog old in npm release 498d4af

1.2.9

26 September 2016

1.2.8

26 September 2016

1.2.7

24 September 2016

  • fixing relative gauge size, pointer position ce54ee2
  • removed auto-adjust example 811caa3
  • hideInnerShadow converted to showInnerShadow, shadow not rendered by default b621d35
  • updated readme 65caf93
  • update date updated :D d8d78cc

1.2.6

23 September 2016

1.2.5

23 September 2016

1.2.4

23 September 2016

1.2.3

21 September 2016

  • Fixing filter paths trying to fetch invalid URLs #245
  • Allow config to be updated in refresh fn. Useful for dynamically set… #210
  • 206 - maxTxt is used for both min and max when reverse is true #208

  • fix #194 #194
  • added onAnimationEnd event hook 0bca41e
  • Set min and max text 73cbf1e
  • minTxt & maxTxt params c0a34ec
  • Fix param name d1bc47d
  • Allow config to be updated in refresh fn. Useful for dynamically setting decimal places etc. ce021d6
  • Add custom value to display. 8109d7a
  • 206 e5be348

  • Update README.md 8bf0c21
  • Update README.md b0fc8e4
  • 193 5bffb51

1.2.2

27 January 2016

  • add three new visual options (title position/font, value font) #190
  • demo for font options 6fdcfbf
  • add three new visual options 5ba12ff
  • version update 71722a6
  • remove line d6470f6

v1.2.1

5 January 2016

v1.2.0

31 December 2015

  • Defaults feature - option to define common config object when you're creating multiple gauges #176
  • fixed shadow id issue and reorganized structure a bit 58bf1fc
  • testing issue with prototype reference 4732dd8
  • reindented 0f9ff93
  • reverse & pointer features 4bb87fc
  • Delete justgage-1.0.1.js 1ff9c84
  • defaults feature b6de58c
  • updatetd bower.json spec 30c56fb
  • added node module feature b6605d0
  • small updates to examples fa937be
  • added license file c27622c
  • minor examples fixes 6c4c267
  • Update README.md ea6f003
  • nothing important :) bebb787
  • defaults feature d0e055e
  • testing decimals b6b3554
  • removed excessive spaces 288b9d9
  • Update README.md 39ad4a7
  • removed trailing comma 212b22e
  • another update of bower.json spec ae3f6ef

v1.1.0

29 July 2015

  • fix #108 #108
  • Add bower.json #91
  • Removed split attempt on array (Issue #100) #101
  • fix #96 Browser compatibiliy problem with attributes.dy (Firefox 25.0 among others) #97
  • Bugfix, that allows setting max to 0 #62
  • Make "hideValue" working #58
  • Add external rendering function for displayed value #21
  • Add support for human friendly abbreviations on large numbers #7
  • Merge pull request #108 from winterismute/master #108
  • fixed #102 #102
  • Merge pull request #97 from supraLalu/master #96
  • fix #96 #96
  • Update justgage.js #28
  • new demos e95e999
  • 49 fix 8a3de20

  • kvLookup is now part of prototype 3271a79
  • Added support to pass HTML5 data options to render the chart f594149
  • new features - parentNode, width, height 343a501
  • added two more cases for max change a6999b5
  • nothing special, just reindenting f920197
  • Added formatNumber example f094b14
  • kvLookup function now handles datatype conversion and fixed originalValue lookup 25f5585
  • Added formatNumber feature 609a330
  • custom sectors c6a998e
  • rearranging options 2488ca4
  • bower.json config update & justgage.js comment updates ca0a130
  • Small changes 19d5ecf
  • Updated example to include refresh fc5c395
  • Update README.md 88ccce6
  • Added formatNumber to refresh method 2dc51c9
  • Update README.md e4f8d28
  • custom sectors log update 138fc2a
  • Update README.md 2d92951
  • Update README.md 37820de
  • 46 - explicitly converted all vars to numbers in refresh method b34fb0f

  • Update justgage.js fa7adf6
  • createElementNS fix for IE7/8 a0ab815
  • skip generating shadow if IE < 9 429ad9f
  • 49 fix 2f0eaab

  • 46 log 8d3bc15

  • experimenting with refreshmax demo 27cf990
  • Update justgage.js a8e733b
  • Update README.md 12df124
  • Update justgage.js f54b6cc
  • forgot comma on line 288 0432487
  • Semver version 13f8372
  • readme 1bb6cd4
  • nothing special b79ef38
  • new donut config option 58b618c
  • donut start angle, hide params, workaround for tspan dy Raphael issue 573cbe9
  • linked R&D Donut example to current version of script 0533d95
  • updates, check log a9ffaf7
  • added justgage script file d5941d7
    • Option to enable responsive gauge size 3828234
  • arranging the code a bit cd15587
  • clearing some variables + added human friendly option when refreshing too ddce9f8
  • counter feature added 14c3e2f
  • Add support for human friendly abbreviations on large numbers, supported by two new config options: humanFriendly (bool), humanFriendlyDecimal (int) 9bd165a
  • added config options for minimum font sizes e2c7280
  • Fix for bad rendering on specific sizes 494b850
  • add external rendering function for displayed value ef3a0f7
  • Update README.md 0b14419
  • readme.md update log 7195c62
  • update log 318e725
  • Option to hide value text d16c663
  • Update README.md 9a85f31
  • commenting 58ee3e0
  • latest updates comments 248b67f
  • log update 63d06e9
  • fixed issue #45 98732e9
  • Update README.md 57c4d5a
  • merge, nothing special a6e8fc8
  • update log, 25 Nov added dc65ab5
  • Update README.md eb73e38
  • Update README.md 92ecbac
  • Initial commit 0de0332
  • set human friendly max label when refreshing max value 1665278
  • 49 fix abe8b58

  • 46 - f*king brace cec9474

  • issue #46 fix af70497
  • Update README.md c740f60
  • Update README.md f2bbb4e
  • Update README.md 2709995
  • Update README.md 760fa57
  • Update README.md a5f8a9a
  • Updated config.value parameter on gauge refresh 7f152c2
  • update comment added 43050c6
  • just testing 9066dc0
  • realized keeping version name in git ocntrolled file kinda stupid :) fb3b22d
  • moved files to R&D folder 1a04134