Code Monkey home page Code Monkey logo

gaugemeter's Introduction

GaugeMeter.js

This is a bug fixed and modified version of the original Ash Alom gauge meter based on minified version 2.0.0.

An elegant and dynamic animated graphical gauge meter built with jQuery. GaugeMeter.js is highly customizable and includes full-radial, semi-radial & arch dials.


GaugeMeter.js jQuery Plugin by Ash Alom

DEMO: http://ashalom.github.io/GaugeMeter

REPO: https://github.com/AshAlom/GaugeMeter

THIS: https://github.com/Mictronics/GaugeMeter


GaugeMeter.js Features

  • Just one script, there is no dependencies.
  • Built-in themes.
  • HTML5 renders the Canvas content without images.
  • Add custom text & label.
  • Support for any page size and page color.
  • Configure via data attributes, object properties on call or default settings.
  • Update via jQuery call.

Requirements


Implementation

Include the following jQuery & JavaScript Code, CSS and HTML code to render a minimal form of the GaugeMeter.

jQuery & JavaScript Code

<script src="./GaugeMeter.js"></script>
<script>
  $(document).ready(function () {
    $('.GaugeMeter').gaugeMeter();
  });
</script>

CSS Styles

.GaugeMeter {
  position: Relative;
  text-align: Center;
  overflow: Hidden;
  cursor: Default;
}

.GaugeMeter SPAN,
.GaugeMeter B {
  margin: 0 23%;
  width: 54%;
  position: Absolute;
  text-align: Center;
  display: Inline-Block;
  color: RGBa(0, 0, 0, 0.8);
  font-weight: 100;
  font-family: 'Open Sans', Arial;
  overflow: Hidden;
  white-space: NoWrap;
  text-overflow: Ellipsis;
}
.GaugeMeter[data-style='Semi'] B {
  margin: 0 10%;
  width: 80%;
}

.GaugeMeter S,
.GaugeMeter U {
  text-decoration: None;
  font-size: 0.5em;
  opacity: 0.5;
}

.GaugeMeter B {
  color: Black;
  font-weight: 300;
  font-size: 0.5em;
  opacity: 0.8;
}

HTML Code

Minimal Implementation. The code below is all you will need to render a basic gauge meter with 0 indication.

<div class="GaugeMeter" id="GaugeMeter_1"></div>

Basic Implementation. The code below is all you will need to render a basic gauge meter with 10 indication.

<div class="GaugeMeter" id="GaugeMeter_1" data-percent="10"></div>

Update the gauge value and its indication via jQuery.

$('#GaugeMeter_1').gaugeMeter({ percent: 15 });

Below is a list of all the optional parameters, see the Parameter Definitions for more details on how to utilize these data attributes.

<div
  class="GaugeMeter"
  id="GaugeMeter_1"
  data-percent="10"
  data-min="-100"
  data-used="256"
  data-total="1024"
  data-size="200"
  data-prepend="$"
  data-append=".00"
  data-theme="Red-Gold-Green"
  data-color="Blue"
  data-back="Silver"
  data-width="2"
  data-style="Semi"
  data-stripe="2"
  data-animationstep="0"
  data-animate_gauge_colors="1"
  data-animate_text_colors="1"
  data-label="VISA Card"
  data-label_color="#FF0000"
  data-text="Spendings"
  data-text_size="0.22"
  data-fill="#FFFFFF"
  data-showvalue="0"
></div>

Parameter Definitions

The form of the gauge meter can be manipulated by means of the following parameters. These parameters can be passed in to the library via HTML5 tag data attributes, as illustrated in the HTML example code above or as object properties when calling the library. The following table elaborates upon each of the parameter properties.

Attribute Optional Defaults Values Description
data-percent No 0 Any positive integer, between 0 to 100. The value to set the gauge meter to.
data-min Yes null Any integer. The minimum value of the gauge meter. Negative values show in combination with data-showvalue=true.
data-used Yes null Any positive integer. Display a percentage of a value that overrides any data-percent defined count. To show "25%" of 512 GB of RAM being used, you would specify "128" here and "512" for data-total.
data-total Yes null Any positive integer. Display a percentage of a value that overrides any data-percent defined count. To show "25%" of 512 GB of RAM being used, you would specify "512" here and "128" for data-used.
data-text Yes null Any short string. Replaces the data-percent count in the center of the gauge.
data-text_size Yes 0.22 Any positive float between 0.0 and 0.5. Scale factor for text size (indicated value or text in gauge center) in relation to gauge size.
data-prepend Yes null Any string (2 bytes max). Adds this text before the percent count in the center of the gauge.
data-append Yes null Any string (2 bytes max). Adds this text after the percent count in the center of the gauge. Typical use would be a "%" symbol.
data-size Yes 100 Any positive integer. Width & height of the gauge meter in pixels.
data-width Yes 3 Any positive integer. Thickness of the gauge meter progress bar in pixels.
data-style Yes Full Full, Semi or Arch Displays either a full circle, semi-circle or an arched-circle.
data-color Yes #2C94E0 Hex values (#FFFFFF), Red-Green-Blue-Alpha color space (RGBa(255,255,255,1.0)) or HTML color-name (Red) The foreground-color of the gauge meter's progress bar. This value is overridden if data-theme is specified.
data-back Yes RGBa(0,0,0,.06) Hex values (#FFFFFF), Red-Green-Blue-Alpha color space (RGBa(255,255,255,1.0)) or HTML color-name (Green) The background-color of the gauge meter's progress bar.
data-theme Yes Red-Gold-Green
  • Red-Gold-Green
  • Green-Gold-Red
  • Green-Red
  • Red-Green
  • DarkBlue-LightBlue
  • LightBlue-DarkBlue
  • DarkRed-LightRed
  • LightRed-DarkRed
  • DarkGreen-LightGreen
  • LightGreen-DarkGreen
  • DarkGold-LightGold
  • LightGold-DarkGold
  • White
  • Black
Color & gradient themes to fill the foreground-color of the gauge meter's progress bar with.
data-animate_gauge_colors Yes false Boolean, false or true. When enabled, the foreground-color of the gauge meter's progress bar will cycle according to the color value, as directed by the data-theme. If enabled, this overrides any values specified by the data-color.
data-animate_text_colors Yes false Boolean, false or true. When enabled, the percentage text color of the gauge meter will cycle according to the color value, as directed by the data-theme. If enabled, this overrides any values specified by the data-label_color.
data-label Yes null Any short string. Supplemental text label that can appear below the central percentage or text of the gauge meter.
data-label_color Yes Black Hex values (#FFFFFF), Red-Green-Blue-Alpha color space (RGBa(255,255,255,1.0)) or HTML color-name (Blue) The foreground text color of the supplemental text label.
data-stripe Yes 0 Any positive integers. Show the gauge meter's progress bar in solid form or stripe form. If the value is greater than 0, the gauge meter's progress bar changes from a solid to a stripe, where the value is the thickness of the stripes.
data-fill Yes null Hex values (#FFFFFF), Red-Green-Blue-Alpha color space (RGBa(255,255,255,1.0)) or HTML color-name (Blue) Fill color of internal gauge background area where prepend, append and gauge text is shown.
data-animationstep Yes 0 Any positive integer. Step width used for animation when gauge bargraph is drawn. Higher number results in higher animation speed. 0 stops animation.
data-showvalue Yes false Boolean, false or true. Label will show value instead of percent. Gauge bargraph will show 0-100% or computation of data-used and data-total.

See doc.html for more details.

gaugemeter's People

Contributors

mictronics avatar silvio-didonna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gaugemeter's Issues

License clarification

inside GaugeMeter.js there is this comment
"Copyright AshAlom.com All rights reserved."

there is also a LICENCE file saying MIT licence

which is true?
Is it open source, or is it all rights reserved?

how to sensor update gauge esp32 8266 ? i am new to html

great job thanks at first for the great project .......

i am trying to include sensor data in gauge
using esp32

i am able to do in google metter ! example

!DOCTYPE HTML>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['gauge']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Label', 'Value'], ['Memory', 0], ['CPU', 0], ['Network',0]
    ]);

    var options = {
      width: 1500, height: 750,
      redFrom: 90, redTo: 1000,
      yellowFrom:75, yellowTo: 90,
      minorTicks: 50
    };

    var chart = new google.visualization.Gauge(document.getElementById('chart_div'));

    chart.draw(data, options);

    setInterval(function() 
    
    {  

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
var volt = (( parseFloat(this.responseText)/ 4023)*100)
data.setValue(0, 1, volt );
chart.draw(data, options);
}
}

xhttp.open("GET", "/readABC", true);
xhttp.send();

    } ,100);
</script>

but i am unable to lode external data to your gauge ?

pls guide me

i am beginner only

thanks in advance

Recreate demo gauge

If I want to recreate the "1.21 GW" gauge from the demo image, what settings would I need to use then?

data-animate_text_colors=true is not working

when data-animate_text_colors=true is used the animation does not start, it remains at the fixed point of the value. Even if you use the jquery or if you use the data-percent="value"

update gauge using data-used

Hi,
I'm using the following gauge:
<div class='GaugeMeter' id='pv_power_1' data-percent='0' data-min='0' data-total='4200' data-used='1200' data-showvalue='true' data-append='W' data-size='200' data-theme='LightBlue-DarkBlue' data-back='RGBa(0,0,0,.1)' data-animate_gauge_colors='true' data-animate_text_colors='true' data-width='15' data-label='PV1 Power' data-style='Arch' data-label_color='#999' ></div>

both the following update command doesn't works....
$('#pv_power_1').gaugeMeter({used:1000});
or
$('#pv_power_1').attr('data-used','1000').gaugeMeter({percent:0});

how can dynamically update this gauge?
thank you!

Problems with running on IOS / Safari Browser

Hello,
at first a great Thanks to you for sharing your work.
I have implemented this on my page and it work without problems if i use browsers like CHROME, IE, FIREFOX.
But on my mobile devices ( Iphone or Ipad with actual IOS Version) , i see no reaction. The gauge bar also than the text does not appear.
Do you have an idea what could cause this problem ?

Thanks for help.

updating the gauge causes animation to start over

Hi
Thanks for the nice gauge!
a cosmetic issue, but when I set the gauge to say, 70% and then a background process updates it to, say, 73%, the gauge animation re-draws it from 0 to 73%, which is not that nice to see.
Any workaround?

Is it possible to update the gauge without "starting from 0"

Hi, great widget and thanks for the work you've put in,

Two questions:

  1. Would it be possible to update the Gauge from the current position rather than from "0"?
  2. Would be great if I could use knockout and data bind the data-percent valud to a view model rather than using $("#aGauge").gaugeMeter({ percent: 42 });

Again, thanks

Add option for counter text font size

Currently counter text (indicated value) font size scales with gauge size. Scaling factor is hard coded. Make this an option to improve gauge control.

Set to a different value than 100%

Hi,
I need to display a voltage of a battery. Maximum value is 15V. How can I display e.g 8Volts and draw the according circle?
Either the circle is wrong or it displays 40 (guess it calculates the percentage) instead of 8

$("#PreviewGaugeMeter_1").data("percent",voltage);

How can I change there "percent" to a absolute value?

In HTML I tried
data-showvalue="true" data-min=0 data-total=15 data-used=8

Who to set metter over 230% or over 500 range ?

Its me again i am thankful to u ๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ’ฏ๐Ÿ’ฏ

I am desining sensor network

I am unable to set metter value over 100 %

I need to display 230 volt ac in metter

And 2000 c temperature

Pls help thanks in advance ๐Ÿ‘๐Ÿ‘๐Ÿ‘

I am new to web design ..,...๐Ÿ‘๐Ÿ‘๐Ÿ‘โœŠ

How can I manually layout multiple GaugeMeter widgets?

Hi, I'm a new learner of css and I'm tring using your GaugeMeter and I think it's kind of great project.
But now when I try to layout 4 GaugeMeter widgets, I meet some trouble. I want to let them be 2x2, but now they can just be 1x4. So can this GaugeMeter support manually layout? Could you give me some advice? Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.