HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs 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 its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script src="//www.amcharts.com/lib/4/core.js"></script>
<script src="//www.amcharts.com/lib/4/charts.js"></script>
<script src="//www.amcharts.com/lib/4/maps.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/dark.js"></script>
<script src="//www.amcharts.com/lib/4/themes/animated.js"></script>
<script>
am4core.useTheme(am4themes_dark);
am4core.useTheme(am4themes_animated);
</script>
<title>RER-B Breakdown Calender</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div id="chartdiv"></div>
<script src="index.js"></script>
</body>
</html>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
background-color: #30303d;
color: #fff;
overflow: hidden;
margin: 10;
}
#chartdiv {
width: 100%;
height: 100vh;
}
am4core.addLicense("CH211653105");
/* Chart code */
// Themes begin
am4core.useTheme(am4themes_dark);
am4core.useTheme(am4themes_animated);
// Themes end
/**
* This is a copy of a chart created by Antti Lipponen: https://twitter.com/anttilip?lang=en Thanks a lot!
*/
// disclaimer: this data is not accuarate, don't use it for any puroposes
var accidents = {
"JANVIER": [
["Janv01", 0,0,0,0,0,0,1,0],
["Janv02", 0,0,1,0,0,2,2,0],
["Janv03", 0,0,1,0,0,0,3,1],
["Janv04", 0,1,4,1,0,1,1,1],
["Janv05", 0,0,0,1,0,0,0,1],
["Janv06", 0,0,1,0,0,2,0,0],
["Janv07", 0,0,1,2,0,2,0,1],
["Janv08", 0,1,1,6,0,2,1,0],
["Janv09", 0,0,2,2,0,2,0,2],
["Janv10", 0,0,2,4,0,2,0,1],
["Janv11", 0,1,0,1,4,3,0,1],
["Janv12", 0,0,0,2,2,0,1,0],
["Janv13", 0,0,2,0,3,0,0,0],
["Janv14", 0,3,1,0,0,0,2,1],
["Janv15", 0,0,7,0,2,0,1,3],
["Janv16", 0,0,1,2,1,3,1,0],
["Janv17", 0,0,1,3,4,2,0,1],
["Janv18", 0,1,0,0,1,0,3,0],
["Janv19", 0,0,0,3,0,1,0,0],
["Janv20", 0,4,0,0,1,2,1,0],
["Janv21", 0,1,3,0,3,1,1,2],
["Janv22", 0,0,1,1,1,0,3,1],
["Janv23", 0,0,1,2,2,0,0,0],
["Janv24", 0,1,2,1,0,0,1,0],
["Janv25", 0,0,0,0,2,2,0,1],
["Janv26", 0,0,0,1,1,1,1,0],
["Janv27", 0,0,1,0,1,1,0,0],
["Janv28", 0,1,2,0,0,1,1,1],
["Janv29", 0,1,4,1,0,1,0,4],
["Janv30", 0,1,0,1,1,1,0,3],
["Janv31", 0,0,2,0,1,0,0,4]
],
"FÉVRIER": [
["Févr01", 0,1,2,0,3,0,2,1],
["Févr02", 0,0,0,0,2,0,4,0],
["Févr03", 0,0,1,2,0,4,0,0],
["Févr04", 0,1,0,0,0,1,1,3],
["Févr05", 0,0,1,0,2,0,1,0],
["Févr06", 0,0,0,4,0,0,6,0],
["Févr07", 0,1,0,0,0,1,5,3],
["Févr08", 0,0,0,0,0,0,1,1],
["Févr09", 0,0,0,1,2,1,3,0],
["Févr10", 0,1,1,1,0,1,0,0],
["Févr11", 0,1,1,2,4,0,0,0],
["Févr12", 0,0,1,2,2,1,4,3],
["Févr13", 0,1,0,3,0,1,4,4],
["Févr14", 0,4,1,4,2,2,3,2],
["Févr15", 0,2,0,2,1,0,0,2],
["Févr16", 0,0,0,1,1,0,0,1],
["Févr17", 0,0,0,1,1,0,2,0],
["Févr18", 0,0,0,0,2,0,1,2],
["Févr19", 0,2,0,1,1,0,2,0],
["Févr20", 0,1,0,1,1,4,3,4],
["Févr21", 0,2,0,3,1,0,0,4],
["Févr22", 0,0,0,1,0,0,3,1],
["Févr23", 0,0,0,2,0,0,2,0],
["Févr24", 0,0,0,1,0,1,2,0],
["Févr25", 0,1,0,1,6,0,0,0],
["Févr26", 0,0,0,0,0,1,1,0],
["Févr27", 0,1,2,1,1,1,1,1],
["Févr28", 0,1,1,0,3,3,3,3]
],
"MARS": [
["Mars01", 0,1,0,0,1,0,4,0],
["Mars02", 0,0,0,1,2,0,5,0],
["Mars03", 0,1,1,1,3,1,1,0],
["Mars04", 0,0,1,1,1,4,0,0],
["Mars05", 0,1,1,0,0,1,0,2],
["Mars06", 0,0,0,0,0,3,2,1],
["Mars07", 0,1,0,0,2,3,1,2],
["Mars08", 0,1,1,0,1,0,1,0],
["Mars09", 0,0,0,0,2,1,3,0],
["Mars10", 0,0,1,1,0,3,3,1],
["Mars11", 0,0,1,1,0,2,1,0],
["Mars12", 0,3,0,5,0,3,1,0],
["Mars13", 0,3,1,3,0,8,1,2],
["Mars14", 0,1,0,0,0,1,1,0],
["Mars15", 0,2,2,0,2,0,2,0],
["Mars16", 0,0,0,2,3,1,1,0],
["Mars17", 0,0,2,1,0,0,1,0],
["Mars18", 0,1,0,0,2,1,0,2],
["Mars19", 0,1,3,3,0,0,1,0],
["Mars20", 0,1,0,2,0,1,0,2],
["Mars21", 0,0,0,2,0,1,3,0],
["Mars22", 0,0,0,0,1,0,3,0],
["Mars23", 0,0,1,0,1,2,1,0],
["Mars24", 0,0,0,1,2,3,0,0],
["Mars25", 0,0,2,3,0,1,1,1],
["Mars26", 0,1,3,1,1,0,0,2],
["Mars27", 0,0,1,1,0,1,1,1],
["Mars28", 0,0,0,0,0,3,2,0],
["Mars29", 0,0,0,0,2,2,1,3],
["Mars30", 0,0,1,3,0,3,0,0],
["Mars31", 0,0,1,1,1,1,2,0]
],
"AVRIL": [
["Avril01", 0,0,2,3,1,0,0,1],
["Avril02", 0,2,1,0,0,1,1,1],
["Avril03", 0,2,6,1,0,1,1,0],
["Avril04", 0,0,1,0,0,0,1,0],
["Avril05", 0,1,1,0,0,1,0,0],
["Avril06", 0,0,2,0,1,0,3,1],
["Avril07", 0,0,2,4,5,1,2,0],
["Avril08", 0,0,4,1,0,0,1,1],
["Avril09", 0,1,1,2,0,1,1,1],
["Avril10", 0,0,0,2,0,1,4,2],
["Avril11", 0,0,0,0,1,1,0,2],
["Avril12", 0,0,0,0,1,1,1,2],
["Avril13", 0,0,0,1,1,0,2,0],
["Avril14", 0,0,2,0,2,0,1,0],
["Avril15", 0,0,1,3,2,0,0,4],
["Avril16", 0,1,0,0,0,0,0,2],
["Avril17", 0,1,1,4,1,0,1,2],
["Avril18", 0,2,1,0,2,1,2,2],
["Avril19", 0,2,0,0,0,1,3,1],
["Avril20", 0,0,0,0,0,5,0,0],
["Avril21", 0,0,0,1,1,3,0,0],
["Avril22", 0,1,0,2,2,0,0,0],
["Avril23", 0,0,1,8,0,0,2,0],
["Avril24", 0,0,1,2,1,0,2,4],
["Avril25", 0,2,2,2,1,2,1,0],
["Avril26", 0,1,1,1,3,0,0,1],
["Avril27", 0,0,0,2,1,4,1,2],
["Avril28", 0,0,1,0,4,1,1,3],
["Avril29", 0,2,2,0,2,0,2,0],
["Avril30", 0,1,2,3,1,1,0,1]
],
"MAI": [
["Mai01", 0,0,0,1,0,0,1,2],
["Mai02", 0,1,2,4,0,2,1,0],
["Mai03", 0,0,0,2,1,1,2,0],
["Mai04", 0,0,0,1,0,2,1,0],
["Mai05", 0,0,0,0,0,1,1,0],
["Mai06", 0,1,0,1,2,1,0,0],
["Mai07", 0,0,0,5,0,0,1,1],
["Mai08", 0,1,1,1,0,0,2,0],
["Mai09", 0,0,0,2,3,2,1,0],
["Mai10", 0,0,0,2,1,1,3,1],
["Mai11", 0,0,0,2,3,2,0,0],
["Mai12", 0,0,0,1,2,3,1,2],
["Mai13", 0,0,1,1,1,0,1,2],
["Mai14", 0,1,0,0,0,0,1,3],
["Mai15", 0,0,0,0,6,3,1,0],
["Mai16", 0,4,0,2,3,4,1,1],
["Mai17", 0,0,0,0,0,0,1,2],
["Mai18", 0,2,0,2,1,1,1,0],
["Mai19", 0,0,1,0,1,0,1,2],
["Mai20", 0,0,1,2,0,0,0,2],
["Mai21", 0,3,0,3,0,0,0,0],
["Mai22", 0,3,2,0,0,2,2,2],
["Mai23", 0,0,1,2,0,1,4,0],
["Mai24", 0,0,0,0,0,1,1,1],
["Mai25", 0,0,0,0,3,3,3,0],
["Mai26", 0,0,2,3,5,0,1,0],
["Mai27", 0,1,0,0,0,0,1,0],
["Mai28", 0,0,0,0,0,1,6,0],
["Mai29", 0,0,0,6,0,0,2,0],
["Mai30", 0,0,0,0,3,1,3,0],
["Mai31", 0,0,0,0,3,2,3,1]
],
"JUIN": [
["Juin01", 0,0,0,4,2,0,1,1],
["Juin02", 0,1,0,0,1,0,5,3],
["Juin03", 0,1,0,1,3,0,3,1],
["Juin04", 0,2,1,1,2,0,0,0],
["Juin05", 0,0,0,2,3,1,2,1],
["Juin06", 0,1,0,0,1,1,1,1],
["Juin07", 0,2,0,1,1,0,4,0],
["Juin08", 0,0,1,1,1,0,6,0],
["Juin09", 0,0,2,2,1,0,0,2],
["Juin10", 0,1,0,0,1,0,0,0],
["Juin11", 0,2,2,1,1,1,0,0],
["Juin12", 0,0,2,5,1,0,2,2],
["Juin13", 0,2,2,2,2,1,8,3],
["Juin14", 0,0,1,0,3,0,3,2],
["Juin15", 0,3,1,1,1,0,2,0],
["Juin16", 0,0,2,1,2,2,1,0],
["Juin17", 0,1,2,1,1,0,2,1],
["Juin18", 0,2,3,0,0,0,2,1],
["Juin19", 0,2,3,1,0,0,2,0],
["Juin20", 0,2,3,0,1,2,2,3],
["Juin21", 0,3,4,1,1,0,3,0],
["Juin22", 0,0,3,2,4,1,3,0],
["Juin23", 0,0,3,0,2,0,3,0],
["Juin24", 0,0,3,1,2,0,1,0],
["Juin25", 0,1,0,6,1,0,2,1],
["Juin26", 0,1,0,1,0,2,3,1],
["Juin27", 0,0,0,0,5,1,2,1],
["Juin28", 0,0,0,0,1,0,4,3],
["Juin29", 0,0,0,2,0,2,3,0],
["Juin30", 0,0,0,3,0,0,2,0]
],
"JUILLET": [
["Juil01", 0,0,0,2,0,0,3,1],
["Juil02", 0,3,2,0,1,3,1,0],
["Juil03", 0,0,2,0,0,0,3,0],
["Juil04", 0,1,0,0,3,2,1,0],
["Juil05", 0,1,0,0,2,0,2,5],
["Juil06", 0,1,0,0,6,3,1,0],
["Juil07", 0,1,0,0,0,0,2,0],
["Juil08", 0,0,2,0,0,0,2,1],
["Juil09", 0,0,1,0,0,0,1,1],
["Juil10", 0,0,2,0,0,0,1,0],
["Juil11", 0,2,0,0,0,2,1,3],
["Juil12", 0,0,0,1,0,1,0,2],
["Juil13", 0,0,0,2,0,2,2,0],
["Juil14", 0,1,0,0,2,0,1,0],
["Juil15", 0,1,0,1,0,0,0,2],
["Juil16", 0,1,0,1,2,1,0,2],
["Juil17", 0,1,0,0,0,4,1,2],
["Juil18", 0,0,0,1,2,2,0,0],
["Juil19", 0,0,0,0,2,0,2,0],
["Juil20", 0,0,0,1,1,1,2,0],
["Juil21", 0,1,0,1,1,1,0,0],
["Juil22", 0,0,0,1,4,1,0,0],
["Juil23", 0,2,0,0,0,0,3,1],
["Juil24", 0,0,0,0,0,1,3,3],
["Juil25", 0,0,0,1,0,2,1,1],
["Juil26", 0,0,0,0,1,0,0,1],
["Juil27", 0,0,0,1,1,0,1,0],
["Juil28", 0,0,0,0,0,0,6,0],
["Juil29", 0,0,0,1,0,0,0,2],
["Juil30", 0,0,0,0,2,0,0,2],
["Juil31", 0,0,0,0,0,0,0,5]
],
"AOÙT": [
["Août01", 0,0,0,0,0,0,0,1],
["Août02", 0,0,0,1,0,0,1,0],
["Août03", 0,0,0,2,4,0,1,1],
["Août04", 0,2,0,0,0,0,0,0],
["Août05", 0,0,0,0,0,0,0,0],
["Août06", 0,0,0,1,0,0,1,0],
["Août07", 0,2,0,1,0,0,2,2],
["Août08", 0,1,0,0,0,0,0,0],
["Août09", 0,0,0,0,0,0,0,2],
["Août10", 0,0,0,0,1,0,0,0],
["Août11", 0,0,0,0,3,1,0,0],
["Août12", 0,0,0,2,0,1,0,2],
["Août13", 0,0,0,0,2,0,0,1],
["Août14", 0,1,0,0,1,1,0,1],
["Août15", 0,3,0,0,0,0,0,0],
["Août16", 0,0,0,1,1,0,2,1],
["Août17", 0,3,0,1,1,0,4,2],
["Août18", 0,1,0,1,0,1,2,0],
["Août19", 0,3,0,4,1,1,0,3],
["Août20", 0,1,1,0,0,0,1,1],
["Août21", 0,0,2,0,0,0,0,0],
["Août22", 0,0,3,2,3,0,0,2],
["Août23", 0,2,1,0,0,0,1,2],
["Août24", 0,1,0,1,2,0,2,0],
["Août25", 0,1,0,6,3,1,1,0],
["Août26", 0,2,0,3,2,0,0,4],
["Août27", 0,2,0,1,0,0,2,2],
["Août28", 0,0,1,1,0,0,0,1],
["Août29", 0,0,0,4,0,3,0,2],
["Août30", 0,0,0,1,2,1,1,5],
["Août31", 0,0,0,0,0,1,3,0]
],
"SEPTEMBRE": [
["Sept01", 0,1,1,0,0,2,0,0],
["Sept02", 0,3,0,2,0,3,0,3],
["Sept03", 0,0,0,1,0,0,3,2],
["Sept04", 0,3,0,1,0,1,3,0],
["Sept05", 0,2,0,0,0,1,0,0],
["Sept06", 0,3,0,0,2,1,1,1],
["Sept07", 0,1,1,2,1,1,0,1],
["Sept08", 0,0,1,0,0,1,0,1],
["Sept09", 0,0,2,0,4,0,1,3],
["Sept10", 0,0,1,0,0,0,2,1],
["Sept11", 0,0,0,1,0,0,0,1],
["Sept12", 0,2,2,0,1,1,0,0],
["Sept13", 0,1,0,0,0,1,0,2],
["Sept14", 0,1,2,1,2,5,2,0],
["Sept15", 0,0,0,1,2,2,0,0],
["Sept16", 0,0,2,1,0,1,0,2],
["Sept17", 0,0,0,1,0,1,1,1],
["Sept18", 0,0,0,3,0,3,2,0],
["Sept19", 0,1,0,0,0,6,2,6],
["Sept20", 0,1,0,1,0,2,0,2],
["Sept21", 0,1,0,1,1,3,0,5],
["Sept22", 0,2,0,0,2,1,1,0],
["Sept23", 0,2,1,0,1,1,0,1],
["Sept24", 0,2,1,1,1,0,3,1],
["Sept25", 0,1,0,0,0,1,2,0],
["Sept26", 0,1,0,0,0,2,0,2],
["Sept27", 0,0,0,0,1,0,0,1],
["Sept28", 0,1,0,0,0,0,2,0],
["Sept29", 0,0,0,0,2,3,0,1],
["Sept30", 0,0,0,4,1,0,0,0],
],
"OCTOBRE": [
["Oct01", 0,1,0,2,0,0,1,2],
["Oct02", 0,1,0,0,0,1,1,0],
["Oct03", 0,1,0,0,1,3,4,1],
["Oct04", 0,3,0,0,1,1,2,1],
["Oct05", 0,2,0,0,1,1,3,0],
["Oct06", 0,0,2,0,2,2,2,0],
["Oct07", 0,1,3,3,0,0,0,0],
["Oct08", 0,0,0,0,0,0,1,2],
["Oct09", 0,0,2,0,1,1,0,3],
["Oct10", 0,0,1,1,1,2,0,5],
["Oct11", 0,1,0,0,0,1,1,3],
["Oct12", 0,0,0,1,1,4,3,0],
["Oct13", 0,0,0,1,3,2,2,0],
["Oct14", 0,0,2,4,1,1,0,3],
["Oct15", 0,7,3,1,3,1,0,0],
["Oct16", 0,1,3,1,0,1,1,1],
["Oct17", 0,0,1,0,3,1,0,3],
["Oct18", 0,0,0,0,1,4,0,5],
["Oct19", 0,0,0,1,2,1,0,1],
["Oct20", 0,1,1,1,0,2,0,2],
["Oct21", 0,0,3,0,1,0,0,0],
["Oct22", 0,2,0,3,3,0,2,1],
["Oct23", 0,0,2,3,3,2,1,3],
["Oct24", 0,0,2,1,1,5,2,0],
["Oct25", 0,2,0,1,3,3,1,2],
["Oct26", 0,0,0,4,0,2,0,0],
["Oct27", 0,0,0,0,1,1,0,0],
["Oct28", 0,4,1,0,4,0,3,1],
["Oct29", 0,5,0,1,1,0,0,6],
["Oct30", 0,1,1,2,3,2,0,3],
["Oct31", 0,1,2,2,2,4,3,2]
],
"NOVEMBRE": [
["Nov01", 0,1,1,3,0,1,0,1],
["Nov02", 0,4,1,1,0,0,0,1],
["Nov03", 0,0,0,0,3,0,1,0],
["Nov04", 0,2,0,0,2,1,0,0],
["Nov05", 0,1,1,0,1,2,0,3],
["Nov06", 2,1,1,0,0,0,0,0],
["Nov07", 1,1,2,0,2,1,3,1],
["Nov08", 1,4,0,0,1,1,1,1],
["Nov09", 0,1,0,1,0,6,1,2],
["Nov10", 0,1,3,1,3,1,2,0],
["Nov11", 0,2,0,2,0,2,0,0],
["Nov12", 0,1,0,0,3,0,1,4],
["Nov13", 0,1,1,1,0,0,2,0],
["Nov14", 0,1,2,1,5,3,0,1],
["Nov15", 1,1,1,2,0,1,3,1],
["Nov16", 0,0,0,0,3,2,3,2],
["Nov17", 0,0,1,2,2,0,1,0],
["Nov18", 0,3,1,9,2,0,1,0],
["Nov19", 0,2,1,1,5,0,0,0],
["Nov20", 1,1,2,2,1,1,1,1],
["Nov21", 0,2,3,2,5,1,1,5],
["Nov22", 0,0,0,2,0,1,5,2],
["Nov23", 0,2,1,0,3,3,0,0],
["Nov24", 0,0,0,1,4,1,0,1],
["Nov25", 0,0,0,2,1,1,0,2],
["Nov26", 1,1,0,0,0,0,1,0],
["Nov27", 2,0,1,3,0,2,0,0],
["Nov28", 0,2,2,1,1,1,2,0],
["Nov29", 1,2,1,1,4,1,0,0],
["Nov30", 1,0,1,3,1,3,0,0]
],
"DÉCEMBRE": [
["Déc01", 1,0,3,2,1,1,0,0],
["Déc02", 0,3,1,0,2,0,0,0],
["Déc03", 0,1,1,2,0,2,4,0],
["Déc04", 0,0,0,1,0,2,0,0],
["Déc05", 1,1,2,1,2,3,0,0],
["Déc06", 0,1,0,0,3,1,1,0],
["Déc07", 0,0,0,0,3,0,1,0],
["Déc08", 0,0,0,4,2,3,1,0],
["Déc09", 0,1,0,1,1,2,0,0],
["Déc10", 0,0,0,0,0,1,1,0],
["Déc11", 0,0,0,1,0,1,0,0],
["Déc12", 2,2,0,1,0,2,2,0],
["Déc13", 0,1,0,0,1,1,1,0],
["Déc14", 0,1,0,2,0,3,1,0],
["Déc15", 1,1,1,4,0,0,1,0],
["Déc16", 1,0,1,2,2,5,0,0],
["Déc17", 1,3,1,2,0,0,0,0],
["Déc18", 1,0,0,6,2,1,2,0],
["Déc19", 0,0,3,0,0,2,2,0],
["Déc20", 1,0,0,0,1,2,2,0],
["Déc21", 1,1,1,2,0,2,0,0],
["Déc22", 0,0,1,0,3,1,0,0],
["Déc23", 0,0,0,0,0,0,0,0],
["Déc24", 1,2,2,1,0,0,0,0],
["Déc25", 0,0,2,0,1,1,0,0],
["Déc26", 0,0,1,1,0,0,0,0],
["Déc27", 0,0,2,1,0,2,2,0],
["Déc28", 1,0,1,1,0,1,0,0],
["Déc29", 1,0,0,0,0,1,0,0],
["Déc30", 1,0,0,0,1,0,0,0],
["Déc31", 0,0,0,0,0,0,1,0]
],
}
var startYear = 2012;
var endYear = 2019;
var currentYear = 2012;
var colorSet = new am4core.ColorSet();
var chart = am4core.create("chartdiv", am4charts.RadarChart);
chart.hiddenState.properties.opacity = 0;
chart.startAngle = 270 - 180;
chart.endAngle = 270 + 180;
chart.padding(5, 15, 5, 10)
chart.radius = am4core.percent(65);
chart.innerRadius = am4core.percent(40);
// year label goes in the middle
var yearLabel = chart.radarContainer.createChild(am4core.Label);
yearLabel.horizontalCenter = "middle";
yearLabel.verticalCenter = "middle";
yearLabel.fill = am4core.color("#A569BD");
yearLabel.fontSize = 40;
yearLabel.text = String(currentYear);
// zoomout button
var zoomOutButton = chart.zoomOutButton;
zoomOutButton.dx = 0;
zoomOutButton.dy = 0;
zoomOutButton.marginBottom = 15;
zoomOutButton.parent = chart.rightAxesContainer;
// scrollbar
chart.scrollbarX = new am4core.Scrollbar();
chart.scrollbarX.parent = chart.rightAxesContainer;
chart.scrollbarX.orientation = "vertical";
chart.scrollbarX.align = "center";
chart.scrollbarX.exportable = false;
// vertical orientation for zoom out button and scrollbar to be positioned properly
chart.rightAxesContainer.layout = "vertical";
chart.rightAxesContainer.padding(120, 20, 120, 20);
// category axis
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.renderer.grid.template.location =0;
categoryAxis.dataFields.category = "dateInMonth";
var categoryAxisRenderer = categoryAxis.renderer;
var categoryAxisLabel = categoryAxisRenderer.labels.template;
categoryAxisLabel.location = 0.5;
categoryAxisLabel.radius = 30;
categoryAxisLabel.relativeRotation = 90;
categoryAxisLabel.disabled=true;
categoryAxisRenderer.fontSize = 9;
categoryAxisRenderer.minGridDistance = 0.5;
categoryAxisRenderer.grid.template.radius = -20;
categoryAxisRenderer.grid.template.strokeOpacity = 0.03;
categoryAxisRenderer.grid.template.interactionsEnabled = false;
categoryAxisRenderer.ticks.template.disabled = false;
categoryAxisRenderer.axisFills.template.disabled = false;
categoryAxisRenderer.line.disabled = true;
categoryAxisRenderer.tooltipLocation = 0.5;
categoryAxis.tooltip.defaultState.properties.opacity = 0;
// value axis
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.min = 0;
valueAxis.max = 10;
valueAxis.strictMinMax = true;
valueAxis.tooltip.defaultState.properties.opacity = 0;
valueAxis.tooltip.animationDuration = 0;
valueAxis.cursorTooltipEnabled = true;
valueAxis.zIndex = 10;
var valueAxisRenderer = valueAxis.renderer;
valueAxisRenderer.axisFills.template.disabled = true;
valueAxisRenderer.ticks.template.disabled = true;
valueAxisRenderer.minGridDistance = 1;
valueAxisRenderer.grid.template.strokeOpacity = 0.03;
valueAxisRenderer.fontSize=7
valueAxisRenderer.fill=am4core.color("#673AB7");
// series
var series = chart.series.push(new am4charts.RadarColumnSeries());
series.columns.template.width = am4core.percent(90);
series.columns.template.strokeOpacity = 0;
series.dataFields.valueY = "value" + currentYear;
series.dataFields.categoryX = "dateInMonth";
series.tooltipText = "{categoryX} : {valueY.value}"+" accidents";
// this makes columns to be of a different color, depending on value
series.heatRules.push({ target: series.columns.template, property: "fill", minValue: 0, maxValue: 6, min: am4core.color("#673AB7"), max: am4core.color("#F44336"), dataField: "valueY" });
// cursor
var cursor = new am4charts.RadarCursor();
chart.cursor = cursor;
cursor.behavior = "zoomX";
cursor.xAxis = categoryAxis;
cursor.innerRadius = am4core.percent(40);
cursor.lineY.disabled = true;
cursor.lineX.fillOpacity = 0.2;
cursor.lineX.fill = am4core.color("#000000");
cursor.lineX.strokeOpacity = 0;
cursor.fullWidthLineX = true;
// year slider
var yearSliderContainer = chart.createChild(am4core.Container);
yearSliderContainer.layout = "vertical";
yearSliderContainer.padding(0, 38, 0, 38);
yearSliderContainer.width = am4core.percent(100);
var yearSlider = yearSliderContainer.createChild(am4core.Slider);
yearSlider.events.on("rangechanged", function() {
updateRadarData(startYear + Math.round(yearSlider.start * (endYear - startYear)));
})
yearSlider.orientation = "horizontal";
yearSlider.start = 0.5;
yearSlider.exportable = false;
chart.data = generateRadarData();
function generateRadarData() {
var data = [];
var i = 0;
for (var month in accidents) {
var monthData = accidents[month];
monthData.forEach(function(dateInMonth) {
var rawDataItem = { "dateInMonth": dateInMonth[0] }
for (var y = 1; y < dateInMonth.length; y++) {
rawDataItem["value" + (startYear + y-1)] = dateInMonth[y];
}
data.push(rawDataItem);
});
createRange(month, monthData, i);
i++;
}
return data;
}
function updateRadarData(year) {
if (currentYear != year) {
currentYear = year;
yearLabel.text = String(currentYear);
series.dataFields.valueY = "value" + currentYear;
chart.invalidateRawData();
}
}
function createRange(name, monthData, index) {
var axisRange = categoryAxis.axisRanges.create();
axisRange.axisFill.interactionsEnabled = true;
axisRange.text = name;
// first dateInMonth
axisRange.category = monthData[0][0];
// last dateInMonth
axisRange.endCategory = monthData[monthData.length-1][0];
// every 3rd color for a bigger contrast
axisRange.axisFill.fill = colorSet.getIndex(index * 3);
axisRange.grid.disabled = true;
axisRange.label.interactionsEnabled = false;
var axisFill = axisRange.axisFill;
axisFill.innerRadius = -0.001; // almost the same as 100%, we set it in pixels as later we animate this property to some pixel value
axisFill.radius = -20; // negative radius means it is calculated from max radius
axisFill.disabled = false; // as regular fills are disabled, we need to enable this one
axisFill.fillOpacity = 1;
axisFill.togglable = true;
axisFill.showSystemTooltip = true;
axisFill.readerTitle = "click to zoom";
axisFill.cursorOverStyle = am4core.MouseCursorStyle.pointer;
axisFill.events.on("hit", function(event) {
var dataItem = event.target.dataItem;
if (!event.target.isActive) {
categoryAxis.zoom({ start: 0, end: 1 });
}
else {
categoryAxis.zoomToCategories(dataItem.category, dataItem.endCategory);
}
})
// hover state
var hoverState = axisFill.states.create("hover");
hoverState.properties.innerRadius = -10;
hoverState.properties.radius = -25;
var axisLabel = axisRange.label;
axisLabel.location = 0.5;
axisLabel.fill = am4core.color("#ffffff");
axisLabel.radius = 2;
axisLabel.bent = true;
}
var slider = yearSliderContainer.createChild(am4core.Slider);
slider.start = 1;
slider.exportable = false;
slider.events.on("rangechanged", function() {
var start = slider.start;
chart.startAngle = 270 - start * 179 - 1;
chart.endAngle = 270 + start * 179 + 1;
valueAxis.renderer.axisAngle = chart.startAngle;
})
Also see: Tab Triggers