chart-pie-demo.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Set new default font family and font color to mimic Bootstrap's default styling
  2. Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
  3. Chart.defaults.global.defaultFontColor = '#858796';
  4. // Pie Chart Example
  5. var ctx = document.getElementById("myPieChart");
  6. var myPieChart = new Chart(ctx, {
  7. type: 'doughnut',
  8. data: {
  9. labels: ["Direct", "Referral", "Social"],
  10. datasets: [{
  11. data: [55, 30, 15],
  12. backgroundColor: ['#4e73df', '#1cc88a', '#36b9cc'],
  13. hoverBackgroundColor: ['#2e59d9', '#17a673', '#2c9faf'],
  14. hoverBorderColor: "rgba(234, 236, 244, 1)",
  15. }],
  16. },
  17. options: {
  18. maintainAspectRatio: false,
  19. tooltips: {
  20. backgroundColor: "rgb(255,255,255)",
  21. bodyFontColor: "#858796",
  22. borderColor: '#dddfeb',
  23. borderWidth: 1,
  24. xPadding: 15,
  25. yPadding: 15,
  26. displayColors: false,
  27. caretPadding: 10,
  28. },
  29. legend: {
  30. display: false
  31. },
  32. cutoutPercentage: 80,
  33. },
  34. });