Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Gauge Chart</title>
  <script src=""></script>
  <script src=""></script>

  <div id="canvas-holder" style="width:100%">
    <canvas id="chart"></canvas>
  <button id="randomizeData">Randomize Data</button>



                canvas {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;



                var randomScalingFactor = function() {
  return Math.round(Math.random() * 100);

var randomData = function () {
  return [

var randomValue = function (data) {
  return Math.max.apply(null, data) * Math.random();

var data = randomData();
var value = randomValue(data);

var config = {
  type: 'gauge',
  data: {
    //labels: ['Success', 'Warning', 'Warning', 'Error'],
    datasets: [{
      data: data,
      value: value,
      backgroundColor: ['green', 'yellow', 'orange', 'red'],
      borderWidth: 2
  options: {
    responsive: true,
    title: {
      display: true,
      text: 'Gauge chart'
    layout: {
      padding: {
        bottom: 30
    needle: {
      // Needle circle radius as the percentage of the chart area width
      radiusPercentage: 2,
      // Needle width as the percentage of the chart area width
      widthPercentage: 3.2,
      // Needle length as the percentage of the interval between inner radius (0%) and outer radius (100%) of the arc
      lengthPercentage: 80,
      // The color of the needle
      color: 'rgba(0, 0, 0, 1)'
    valueLabel: {
      formatter: Math.round

window.onload = function() {
  var ctx = document.getElementById('chart').getContext('2d');
  window.myGauge = new Chart(ctx, config);

document.getElementById('randomizeData').addEventListener('click', function() { { = randomData();
    dataset.value = randomValue(;