Created
March 4, 2018 08:07
-
-
Save m-root/dff7d705e303bed8ab74466b602295da to your computer and use it in GitHub Desktop.
CHARTIST.JS Charts implementation in html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Chartist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" href="https://rawgit.com/gionkunz/chartist-js/master/dist/chartist.min.css"> | |
<style> | |
</style> | |
</head> | |
<body> | |
<div class="ct-chart chart" id="chart"></div> | |
<div class="ct-chart " id="simple-gauge-chart"></div> | |
<div id="chartHours" class="ct-chart"></div> | |
<div id="chartPreferences" class="ct-chart ct-perfect-fourth"></div> | |
<div id="chartActivity" class="ct-chart"></div> | |
<script type="text/javascript" src="https://rawgit.com/gionkunz/chartist-js/master/dist/chartist.js"></script> | |
<script> | |
new Chartist.Line('#chart', { | |
labels: [1, 2, 3, 4, 5, 6, 7, 8], | |
series: [ | |
[5, 9, 7, 8, 5, 3, 5, 4] | |
] | |
}, { | |
low: 0, | |
showArea: true | |
}); | |
var dataSales = { | |
labels: ['9:00AM', '12:00AM', '3:00PM', '6:00PM', '9:00PM', '12:00PM', '3:00AM', '6:00AM'], | |
series: [ | |
[287, 385, 490, 562, 594, 626, 698, 895, 952], | |
[67, 152, 193, 240, 387, 435, 535, 642, 744], | |
[23, 113, 67, 108, 190, 239, 307, 410, 410] | |
] | |
}; | |
var optionsSales = { | |
lineSmooth: false, | |
low: 0, | |
high: 1000, | |
showArea: true, | |
height: "245px", | |
axisX: { | |
showGrid: false, | |
}, | |
lineSmooth: Chartist.Interpolation.simple({ | |
divisor: 3 | |
}), | |
showLine: true, | |
showPoint: false, | |
}; | |
var responsiveSales = [ | |
['screen and (max-width: 640px)', { | |
axisX: { | |
labelInterpolationFnc: function (value) { | |
return value[0]; | |
} | |
} | |
}] | |
]; | |
Chartist.Line('#chartHours', dataSales, optionsSales, responsiveSales); | |
var data = { | |
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], | |
series: [ | |
[542, 543, 520, 680, 653, 753, 326, 434, 568, 610, 756, 895], | |
[230, 293, 380, 480, 503, 553, 600, 664, 698, 710, 736, 795] | |
] | |
}; | |
var options = { | |
seriesBarDistance: 10, | |
axisX: { | |
showGrid: false | |
}, | |
height: "245px" | |
}; | |
var responsiveOptions = [ | |
['screen and (max-width: 640px)', { | |
seriesBarDistance: 5, | |
axisX: { | |
labelInterpolationFnc: function (value) { | |
return value[0]; | |
} | |
} | |
}] | |
]; | |
Chartist.Line('#chartActivity', data, options, responsiveOptions); | |
var dataPreferences = { | |
series: [ | |
[25, 30, 20, 25] | |
] | |
}; | |
var optionsPreferences = { | |
donut: true, | |
donutWidth: 40, | |
startAngle: 0, | |
total: 100, | |
showLabel: false, | |
axisX: { | |
showGrid: false | |
} | |
}; | |
Chartist.Pie('#chartPreferences', dataPreferences, optionsPreferences); | |
Chartist.Pie('#chartPreferences', { | |
labels: ['62%','32%','6%'], | |
series: [62, 32, 6] | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment