Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                
<div class="flex-container">
	<div class="flex-row">
	   <canvas id="keyNumbers" width="400" height="100" aria-label="Chiffres clés de Sanofi"  role="img"></canvas>
    <img src="https://media.gettyimages.com/vectors/world-map-circle-vector-with-white-background-vector-id693373704" style="width:200px;">
	</div>
	
	<div class="flex-row">
    <button id="#2014" onclick="myFunction2014()" value="update graph">2014</button> 
		<button id="#2015" onclick="myFunction2015()" value="update graph">2015</button> <button id="#2016" onclick="myFunction2016()" value="update graph">2016</button> <button id="#2017" onclick="myFunction2017()" value="update graph">2017</button>	<button id="#2018" onclick="myFunction2018()" value="update graph">2018</button> <button id="#2019" onclick="myFunction2019()" value="update graph">2019</button>
	</div>
</div>
    


              
            
!

CSS

              
                html {
    color: #222;
    font-size: 1em;
    line-height: 1.4;
}


body {
    font: 16px/26px Helvetica, Helvetica Neue, Arial;
}

/*===========
    Flex grid
   =============== */
.flex-container {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 0 1em;
}
@media (min-width: 540px) {
  .flex-container {
    max-width: 540px;
  }
}
@media (min-width: 768px) {
  .flex-container {
    max-width: 768px;
  }
}
@media (min-width: 992px) {
  .flex-container {
    max-width: 992px;
  }
}
@media (min-width: 1200px) {
  .flex-container {
    max-width: 1200px;
  }
}

.flex-row {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 1em;
  justify-content:center
}
button{
  margin:0 15px
}
img{
  width: 200px;
		position: absolute;
		top: 28px;
		z-index:-1
}
              
            
!

JS

              
                window.chartColors = {
	green: '#BCBC1C',
	blue: '#525CA3',
	purple: '#C7B1D4',
	light:"#DFD7D4",
  primary:"#6B747B",
  brown:"#CAAE7A",
  mauve:"#A7877C"
};



var ctx = document.getElementById('keyNumbers').getContext('2d');
var myDoughnutChart = new Chart(ctx, {
    type: 'doughnut',
	 data: {
  datasets: [{
        data: [12391,8679,3363,2529,1156,2763,3612],
        backgroundColor: [
        window.chartColors.blue,
        window.chartColors.green,
        window.chartColors.purple,
		    window.chartColors.light,
        window.chartColors.primary,
        window.chartColors.brown,
        window.chartColors.mauve, 
      ]
      }],
      labels: [
        "Etats-Unis: 12 391 M€",
        "Europe: 8 679 M€",
        "Amérique Latine: 3363 M€",
        "Asie :2 529 M€",
        "Eurasie: 1156 M€",
        "Afrique et Moyen Orient: 2763 M€",
        "RDM: 3 612 M€"
      ]
    },
    options: {
	cutoutPercentage: 85, //width of the stroke
	responsive: true,
	legend: {
	onClick: function (e) {
		e.stopPropagation();
		},
	  position: 'bottom',
	},
   
    animation: {
      animateScale: true,
      animateRotate: true
    },

    tooltips: {
    callbacks: {
      label: function(tooltipItem, data) {
        var dataset = data.datasets[tooltipItem.datasetIndex];
        var meta = dataset._meta[Object.keys(dataset._meta)[0]];
        var total = meta.total;
        var currentValue = dataset.data[tooltipItem.index];
        var percentage = parseFloat((currentValue/total*100).toFixed(1));
        return  percentage + '%';
      },
      title: function(tooltipItem, data) {
        return data.labels[tooltipItem[0].index];
      }
    }
  },
  
  }
});
function myFunction2014() {
    myDoughnutChart.data.datasets[0].data[0] = "11339", 
	myDoughnutChart.data.datasets[0].data[1] = "9062",
	myDoughnutChart.data.datasets[0].data[2] = "3363",
	myDoughnutChart.data.datasets[0].data[3] = "2529",
	myDoughnutChart.data.datasets[0].data[4] = "1344",
	myDoughnutChart.data.datasets[0].data[5] = "2449",
	myDoughnutChart.data.datasets[0].data[6] = "3612",
	myDoughnutChart.data.labels[0] = "Etats-Unis: 11339 M€",
	myDoughnutChart.data.labels[1] = "Europe: 9062 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine: 3363 M€",
	myDoughnutChart.data.labels[3] = "Asie :2 529 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1344 M€",
	myDoughnutChart.data.labels[5] = "Afrique et Moyen Orient: 2 449 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3 612 M€",

    myDoughnutChart.update();
}
function myFunction2015() {
    myDoughnutChart.data.datasets[0].data[0] = "13406", 
	myDoughnutChart.data.datasets[0].data[1] = "9299",
	myDoughnutChart.data.datasets[0].data[2] = "3305",
	myDoughnutChart.data.datasets[0].data[3] = "3288",
	myDoughnutChart.data.datasets[0].data[4] = "1156",
	myDoughnutChart.data.datasets[0].data[5] = "2763",
	myDoughnutChart.data.datasets[0].data[6] = "3706",
	myDoughnutChart.data.labels[0] = "Etats-Unis: 13406 M€",
	myDoughnutChart.data.labels[1] = "Europe: 9299 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine: 3305 M€",
	myDoughnutChart.data.labels[3] = "Asie: 3288 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1156 M€",
	myDoughnutChart.data.labels[5] = "Afrique et Moyen Orient: 2763 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3706 M€",
	

    myDoughnutChart.update();
}
function myFunction2016() {
    myDoughnutChart.data.datasets[0].data[0] = "12391", 
	myDoughnutChart.data.datasets[0].data[1] = "8679",
	myDoughnutChart.data.datasets[0].data[2] = "2503",
	myDoughnutChart.data.datasets[0].data[3] = "3468",
	myDoughnutChart.data.datasets[0].data[4] = "10902",
	myDoughnutChart.data.datasets[0].data[5] = "2405",
	myDoughnutChart.data.datasets[0].data[5] = "3158",
	myDoughnutChart.data.labels[0] = "Etats-Unis: 12 391 M€",
	myDoughnutChart.data.labels[1] = "Europe: 8 679 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine:2503 M€",
	myDoughnutChart.data.labels[3] = "Asie: 3 468 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1090 M€",
	myDoughnutChart.data.labels[5] = "Afrique et Moyen Orient: 2 405 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3 158 M€",

    myDoughnutChart.update();
}

function myFunction2017() {
    myDoughnutChart.data.datasets[0].data[0] = "11855", 
	myDoughnutChart.data.datasets[0].data[1] = "9525",
	myDoughnutChart.data.datasets[0].data[2] = "2837",
	myDoughnutChart.data.datasets[0].data[3] = "3732",
	myDoughnutChart.data.datasets[0].data[4] = "1242",
	myDoughnutChart.data.datasets[0].data[5] = "2326",
	myDoughnutChart.data.datasets[0].data[6] = "3417"
	myDoughnutChart.data.labels[0] = "Etats-Unis: 11 855 M€",
	myDoughnutChart.data.labels[1] = "Europe: 9525 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine: 2 837 M€",
	myDoughnutChart.data.labels[3] = "Asie : 3 732 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1 242 M€",
	myDoughnutChart.data.labels[5] = "Afrique et Moyen Orient: 2 326 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3 417 M€",

    myDoughnutChart.update();
}

function myFunction2018() {
    myDoughnutChart.data.datasets[0].data[0] = "11540", 
	myDoughnutChart.data.datasets[0].data[1] = "9434",
	myDoughnutChart.data.datasets[0].data[2] = "2612",
	myDoughnutChart.data.datasets[0].data[3] = "3962",
	myDoughnutChart.data.datasets[0].data[4] = "1152",
	myDoughnutChart.data.datasets[0].data[5] = "2232",
	myDoughnutChart.data.datasets[0].data[6] = "3377"
	myDoughnutChart.data.labels[0] = "Etats-Unis: 11 540M€",
	myDoughnutChart.data.labels[1] = "Europe: 9 434 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine: 2 612 M€",
	myDoughnutChart.data.labels[3] = "Asie : 3  962 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1152 M€",
	myDoughnutChart.data.labels[5] = "Afrique et Moyen Orient: 2232 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3 377 M€",
	 myDoughnutChart.update();
}
function myFunction2019() {
  
	 myDoughnutChart.data.datasets[0].data[0] = "12756", 
	myDoughnutChart.data.datasets[0].data[1] = "8852",
	myDoughnutChart.data.datasets[0].data[2] = "2734",
	myDoughnutChart.data.datasets[0].data[3] = "4393",
	myDoughnutChart.data.datasets[0].data[4] = "1312",
	myDoughnutChart.data.datasets[0].data[5] = "2307",
	myDoughnutChart.data.datasets[0].data[6] = "3604",
    myDoughnutChart.data.labels[0] = "Etats-Unis: 12 756 M€",
	myDoughnutChart.data.labels[1] = "Europe: 8 852 M€",
	myDoughnutChart.data.labels[2] = "Amérique Latine: 2734 M€",
	myDoughnutChart.data.labels[3] = "Asie: 4 393 M€",
	myDoughnutChart.data.labels[4] = "Eurasie: 1 312 M€",
	myDoughnutChart.data.labels[5] = "Afrique & Moyen Orient : 2 307 M€",
	myDoughnutChart.data.labels[6] = "RDM: 3 604 M€",
    myDoughnutChart.update();
}
              
            
!
999px

Console