Basic Column Chart - CanvasJS
Basic Column Chart
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div class="slideshow-container">
<div class="mySlides">
<q id = "quotes">January</q>
</div>
<div class="mySlides">
<q id = "quotes">Febuary</q>
</div>
<div class="mySlides">
<q id = "quotes">March</q>
</div>
<div class="mySlides">
<q id = "quotes">April</q>
</div>
<div class="mySlides">
<q id = "quotes">May</q>
</div>
<div class="mySlides">
<q id = "quotes">June</q>
</div>
<div class="mySlides">
<q id = "quotes">July</q>
</div>
<div class="mySlides">
<q id = "quotes">August</q>
</div>
<div class="mySlides">
<q id = "quotes">September</q>
</div>
<div class="mySlides">
<q id = "quotes">October</q>
</div>
<div class="mySlides">
<q id = "quotes">November</q>
</div>
<div class="mySlides">
<q id = "quotes">December</q>
</div>
<button type="button" class="prev" onclick="plusSlides(-1)">❮</button>
<button type="button" class="next" onclick="plusSlides(1)">❯</button>
</div>
<div class="dot-container">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
<span class="dot" onclick="currentSlide(4)"></span>
<span class="dot" onclick="currentSlide(5)"></span>
<span class="dot" onclick="currentSlide(6)"></span>
<span class="dot" onclick="currentSlide(7)"></span>
<span class="dot" onclick="currentSlide(8)"></span>
<span class="dot" onclick="currentSlide(9)"></span>
<span class="dot" onclick="currentSlide(10)"></span>
<span class="dot" onclick="currentSlide(11)"></span>
<span class="dot" onclick="currentSlide(12)"></span>
</div>
<div...
CSS
.slideshow-container {
position: relative;
background: #f1f1f1f1;
margin-top: 100px;
height: 100px;
align-items: center;
}
/* Slides */
.mySlides {
display: none;
padding: 3px;
text-align: center;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -30px;
padding: 16px;
color: #888;
font-weight: bold;
font-size: 20px;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
position: absolute;
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
color: white;
}
/* The dot/bullet/indicator container */
.dot-container {
text-align: center;
padding: 8px;
background: #ddd;
height: 10px;
padding-bottom: 30px;
align-items: center;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 10px;
width: 10px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
/* Add a background color to the active dot/circle */
.active, .dot:hover {
background-color: #717171;
}
/* Add an italic font style to all quotes */
q {
font-style: italic;
font-size: 60px;
font-weight: bold;
}
JavaScript
<?php
$con = mysqli_connect("localhost","root","","oatdistribution");
//January
$piesql = "SELECT Status, count(*) as Total FROM jan GROUP BY Status";
$pieresult = mysqli_query($con,$piesql);
while($row = mysqli_fetch_assoc($pieresult))
{
$dataPoints[] = array("label"=>$row['Status'], "y"=>$row['Total']);
}
//Febuary
$piesql2 = "SELECT Status, count(*) as Total FROM feb GROUP BY Status";
$pieresult2 = mysqli_query($con,$piesql2);
while($row = mysqli_fetch_assoc($pieresult2))
{
$dataPoints2[] = array("label2"=>$row['Status'], "y2"=>$row['Total']);
}
?>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
if(slideIndex == 1){
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
animationEnabled: true,
legend:{
verticalAlign: "bottom",
horizontalAlign: "center"
},
data: [{
indexLabel: "{label} ({y} people)",
yValueFormatString: "#,##0.\"\"",
indexLabelFontSize: 17,
indexLabelFontFamily: "Garamond",
indexLabelFontColor: "black",
indexLabelLineColor: "black",
indexLabelPlacement: "outside",
type: "pie",
...