Pie Chart

Config Windows

by chrischilcoat

HTML

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

<div class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: block;">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel">Setup your Circle Chart</h4>
      </div>
      <div class="modal-body clearfix">
        <div class="row" style="background:#efefef; margin:-20px -20px 20px; padding:20px 8px 0;">
          <div class="col-xs-12">
            <div class="panel panel-default">
              <div class="panel-body">
               <div class="ui-yakabox-chart-wrapper">
               <div class="row">
                 <div class="col-sm-7">
                   <div id="doughnutChart" class="chart">
                   </div>
                 </div>
                 <div class="col-sm-5">
                   <ul class="list-group">
                     <li class="list-group-item"><i class="fa fa-circle" style="color:#35a8ff;"></i> Time Used</li>
                     <li class="list-group-item"><i class="fa fa-circle" style="color:#f3e32b;"></i> Enroll Time</li>
                     <li class="list-group-item"><i class="fa fa-circle"></i> Time Remaining</li>
                   </ul>
                 </div>
                 </div>
               </div>
             </div>
            </div>
          </div>
        </div>
  ...

SCSS

.control-label {
  text-align:left !important;
}
.modal-dialog {
  max-width:600px;
}
.chart {
  margin: 0 auto;
  width: 250px;
  height: 250px;
  position: relative;
}
.doughnutTip {
  position: absolute;
  float: left;
  min-width: 30px;
  max-width: 300px;
  padding: 5px 15px;
  border-radius: 1px;
  background: rgba(0,0,0,.8);
  color: #ddd;
  font-size: 17px;
  text-shadow: 0 1px 0 #000;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.3;
  letter-spacing: .06em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transform: all .3s;
  pointer-events: none;
}
.doughnutTip:after {
  position: absolute;
  left: 50%;
  bottom: -6px;
  content: "";
  height: 0;
  margin: 0 0 0 -6px;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  border-top: 6px solid rgba(0,0,0,.7);
  line-height: 0;
}
.doughnutSummary {
  display:none;
}
.doughnutSummaryTitle {
  display:none;
}
.doughnutTypeTitle {
  display:none;
}
.doughnutSummaryNumber {
  display:none;
}
.chart path:hover { 
  opacity: .65; 
}
.ui-yakabox-chart-wrapper {
  .list-group {
   // text-align:center;
    margin:0;
    margin-top:90px;
    .list-group-item {
      //display:inline-block;
      border:none;
      //text-align:center;
      padding:0;
    }
  }
}
.form-group .list-group .list-group-item {
  border:none;
  padding:0;
  cursor:pointer;
}

JavaScript

var $btnLT = $(".btnLT"),
  $btnLO = $(".btnLO"),
  $btnLL = $(".btnLL"),
  $chart = $(".ui-yakabox-chart-wrapper"),
  setLabelPositions = function() {
    $chart
      .removeClass('tooltip')
      .removeClass('outside')
      .removeClass('legend');
  },
  setActiveBtn = function() {
    $btnLT.removeClass('active');
    $btnLO.removeClass('active');
    $btnLL.removeClass('active');
  };

$btnLT.on('click', function(event) {
  setActiveBtn();
  setLabelPositions();
  $chart.addClass('toolip');
  $(this).addClass('active');
  event.preventDefault();
});

$btnLO.on('click', function(event) {
  setActiveBtn();
  setLabelPositions();
  $chart.addClass('outside');
  $(this).addClass('active');
  event.preventDefault();
});

$btnLL.on('click', function(event) {
  setActiveBtn();
  setLabelPositions();
  $chart.addClass('legend');
  $(this).addClass('active');
  event.preventDefault();
});





;(function($, undefined) {




  $.fn.drawDoughnutChart = function(data, options) {
    var $this = this,
      W = $this.width(),
      H = $this.height(),
      centerX = W/2,
      centerY = H/2,
      cos = Math.cos,
      sin = Math.sin,
      PI = Math.PI,
      settings = $.extend({
        segmentShowStroke : true,
        segmentStrokeColor : "#fff",
        segmentStrokeWidth : 0,
        baseColor: "rgba(255,255,255,1)",
        baseOffset: 4,
        edgeOffset : 10,//offset from edge of $this
        percentageInnerCutout : 0,
        animation : true,
        animationSteps : 90,
        animationEasing : "easeInOutExpo",
        animateRotate : true,
        tipOffsetX: -8,
        tipOffsetY: -45,
        tipClass: "doughnutTip",
        summaryClass: "doughnutSummary",
        summaryTitle: "DAYS REMAINING:",
        summaryTitleClass: "doughnutSummaryTitle",
        summaryTypeClass: "doughnutTypeTitle",
        summaryNumberClass: "doughnutSummaryNumber",
        beforeDraw: function(){  },
        afterDrawed : function(){  },
        onPathEnter :...