cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <br />
<br />
<br />
<br />
<div class="container">
    <div class="row colors">    
  <button type="button" class="btn orange">Orange</button>
  <button type="button" class="btn red">Red</button>
  <button type="button" class="btn green">Green</button>
  <button type="button" class="btn white">White</button>
  <button type="button" class="btn blue">Blue</button>
  </div>  
  <div class="row"> 
    <div class="col-sm-6">
      <canvas id="chart1"></canvas>
    </div>
    <div class="col-sm-6">
      <canvas id="chart2"></canvas>
    </div>
  </div>
  <div class="row"> 
    <div class="col-sm-4">
      <canvas id="chart3"></canvas>
    </div>
    <div class="col-sm-4">
      <canvas id="chart5"></canvas>
    </div>
        <div class="col-sm-4">
      <canvas id="chart4"></canvas>
    </div>
  </div>
  </div>  
</div>
            
          
!
            
              body{
  background-color: black;
  padding:0px;
}

.orange, .red, .green, .white, .blue{
  background-color: black;
}

.orange:hover{
  color:orange;
}

.red:hover{
  color:red;
}

.green:hover{
  color:green;
}

.white:hover{
  color:white;
}

.blue:hover{
  color:blue;
}

.colors{
  padding-top:10px;
  padding-left:16px;
}

#chart1, #chart2, #chart3, #chart4, #chart5{
 margin-top:40px;
  background-color:black;
  border-radius:6px;
}


            
          
!
            
              // Notes:
// Using bootstrap for the Grid ,Chart.js for the charts and Jquery for the buttons
// Check out my Chart.js blog post if you need help getting started with chart.js


var canvas = document.getElementById("chart1");
var ctx = canvas.getContext('2d');
var canvas2 = document.getElementById("chart2");
var ctx2 = canvas2.getContext('2d');
var canvas3 = document.getElementById("chart3");
var ctx3 = canvas3.getContext('2d');
var canvas4 = document.getElementById("chart4");
var ctx4 = canvas4.getContext('2d');
var canvas5 = document.getElementById("chart5");
var ctx5 = canvas5.getContext('2d');

//Charts:

var chart1, chart2, chart3, chart4, chart5;

// Colors:

var color1 = "rgba(0,255,0,0.2)";
var color2 = "rgba(0,225,0,0.5)";
var color3 = "rgba(0,225,0,0.8)";

// Global Options:
Chart.defaults.global.defaultFontColor = color2;
Chart.defaults.global.defaultFontSize = 10;
Chart.defaults.global.legend.display = false;
Chart.defaults.global.tooltips.enabled = false;

var data = {
  labels: ["", "", "", " ", " ", "", "", "    ", "", "", "", " ", "", "", "", ""],
  datasets: [{
    label: "",
    fill: true,
    lineTension: 0.1,
    borderWidth: 2,
    backgroundColor: color1,
    borderColor: color3, // The main line color
    borderCapStyle: 'square',
    borderDash: [], // try [5, 15] for instance
    borderDashOffset: 0.0,
    borderJoinStyle: 'miter',
    pointBorderWidth: 1,
    pointHoverRadius: 0,
    pointHoverBorderWidth: 2,
    pointRadius: 0,
    pointHitRadius: 10,
    data: [65, 59, 80, 81, 56, 55, 40, 100, 60, 55, 30, 78, 60, 55, 30, 78],
    spanGaps: true,
  }]
};

var data2 = {
  labels: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"],
  datasets: [{
    data: [65, 59, 80, 81, 56, 55, 40, 100, 60, 55, 30, 78, 60, 55, 30, 78],
    borderWidth: 1,
    backgroundColor: color1,
    borderColor: color3 // The main line color
  }]
};

var data3 = {
  datasets: [{
    data: [0, 6, 7, 0, 10],
    borderWidth: 1,
    backgroundColor: color1,
    borderColor: color3 // The main line colo
  }],
  labels: ["", "", "", "", ""]
};

var data4 = {
  datasets: [{
    label: 'First Dataset',
    data: [{
        x: 30,
        y: 20,
        r: 10
      }, {
        x: 10,
        y: 40,
        r: 20
      }, {
        x: 70,
        y: 80,
        r: 10
      }, {
        x: 46,
        y: 25,
        r: 20
      }, {
        x: 20,
        y: 30,
        r: 10
      }, {
        x: 90,
        y: 80,
        r: 20
      }

    ],
    backgroundColor: color1
  }]
};

var options = {
  scales: {
    xAxes: [{
      display: true,
      gridLines: {
        color: color2,
        zeroLineColor: color2
      }
    }],
    yAxes: [{
      display: true,
      gridLines: {
        color: color2,
        zeroLineColor: color2
      },
      ticks: {
        min: 0,
      }
    }]

  }
};

var options2 = {
  scale: {
    gridLines: {
      color: color1
    },
    angleLines: {
      color: color1
    },
    display: true,
    ticks: {
      display: false,
      beginAtZero: true
    }
  }
};

var options3 = {
  scales: {
    xAxes: [{
      display: true,
      gridLines: {
        color: color2,
        zeroLineColor: color2
      },
      ticks: {
        min: 0,
        max: 100
      }
    }],
    yAxes: [{
      display: true,
      gridLines: {
        color: color2,
        zeroLineColor: color2
      },
      ticks: {
        min: 0,
        max: 100
      }
    }]

  }
};

function updateColors() {
  console.log(chart1.data);
  chart1.data.datasets[0].backgroundColor = color1;
  chart1.data.datasets[0].borderColor = color3;
  chart1.options.scales.xAxes[0].gridLines.color = color2;
  chart1.options.scales.xAxes[0].gridLines.zeroLineColor = color2;
  chart1.options.scales.yAxes[0].gridLines.color = color2;
  chart1.options.scales.yAxes[0].gridLines.zeroLineColor = color2;

  chart2.data.datasets[0].backgroundColor = color1;
  chart2.data.datasets[0].borderColor = color3;
  chart2.options.scales.xAxes[0].gridLines.color = color2;
  chart2.options.scales.xAxes[0].gridLines.zeroLineColor = color2;
  chart2.options.scales.yAxes[0].gridLines.color = color2;
  chart2.options.scales.yAxes[0].gridLines.zeroLineColor = color2;

  chart3.data.datasets[0].backgroundColor = color1;
  chart3.data.datasets[0].borderColor = color3;
  chart3.options.scale.gridLines.color = color1;
  chart3.options.scale.angleLines.color = color1;

  chart4.data.datasets[0].backgroundColor = color1;
  chart4.data.datasets[0].borderColor = color3;
  chart4.options.scale.gridLines.color = color1;
  chart4.options.scale.angleLines.color = color1;

  chart5.data.datasets[0].backgroundColor = color1;
  chart5.options.scales.xAxes[0].gridLines.color = color2;
  chart5.options.scales.xAxes[0].gridLines.zeroLineColor = color2;
  chart5.options.scales.yAxes[0].gridLines.color = color2;
  chart5.options.scales.yAxes[0].gridLines.zeroLineColor = color2;

  Chart.defaults.global.defaultFontColor = color2;
  chart1.update();
  chart2.update();
  chart3.update();
  chart4.update();
  chart5.update();

}

$(".orange").click(function() {
  color1 = "rgba(255,165,0,0.2)";
  color2 = "rgba(255,165,0,0.5)";
  color3 = "rgba(255,165,0,0.8)";
  updateColors();
});

$(".red").click(function() {
  color1 = "rgba(255,0,0,0.2)";
  color2 = "rgba(255,0,0,0.5)";
  color3 = "rgba(255,0,0,0.8)";
  updateColors();
});

$(".green").click(function() {
  color1 = "rgba(0,255,0,0.2)";
  color2 = "rgba(0,255,0,0.5)";
  color3 = "rgba(0,255,0,0.8)";
  updateColors();
});

$(".white").click(function() {
  color1 = "rgba(255,255,255,0.2)";
  color2 = "rgba(255,255,255,0.5)";
  color3 = "rgba(255,255,255,0.8)";
  updateColors();
});

$(".blue").click(function() {
  color1 = "rgba(0,0,255,0.2)";
  color2 = "rgba(0,0,255,0.5)";
  color3 = "rgba(0,0,255,0.8)";
  updateColors();
});


function init() {

  // Chart declaration:
  chart1 = new Chart(ctx, {
    type: 'line',
    data: data,
    options: options
  });

  chart2 = new Chart(ctx2, {
    type: 'bar',
    data: data2,
    options: options
  });

  chart3 = new Chart(ctx3, {
    data: data2,
    type: 'radar',
    options: options2
  });

  chart4 = new Chart(ctx4, {
    data: data3,
    type: 'polarArea',
    options: options2
  });

  chart5 = new Chart(ctx5, {
    data: data4,
    type: 'bubble',
    options: options3
  });

}

init();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console