bernii / gauge.js

100% native and cool looking JavaScript gauge
MIT License
1.42k stars 391 forks source link

Please help me. what is the process to add current value?? I am new, please help me. #186

Closed opu8232 closed 6 years ago

opu8232 commented 6 years ago

Please help me. what is the process to add current value?? I am new, please help me.

capture

kplindegaard commented 6 years ago

You have probably figured it out by now, e.g. if you searched old issues like #19. Anyway, here we go:

  1. Define a div, span or whatever you like and give that html element a decent id.
  2. After creating the Gauge or Donut, get a reference to that element and pass it to the Gauge object via the setTextField method.
<body>
  <canvas id="my_canvas"></canvas>
  <span id="my_textfield"></span>

<script type="application/javascript">
var opts = {
   // Deleted the contents of this. Use your own config.
};
var target = document.getElementById('my_canvas'); 
var gauge = new Gauge(target).setOptions(opts); 
gauge.maxValue = 8000; 
gauge.setMinValue(0); 
gauge.animationSpeed = 32; 

// Assign text field
var textField = document.getElementById("my_textfield");
gauge.setTextField(textField);

gauge.set(5000);
</script>
</body>