JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<!-- jquery libs -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- d3.js libs -->
<script src="http://d3js.org/d3.v3.min.js"></script>
<div id="holder">
<div id="machinepie"></div>
</div>
<ul class="testers">
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
</ul>
<style>
.chart{
background: #eeeeee;
}
#holder{
position:relative;
}
.testers{
list-style-type:none;
}
</style>
</body>
</html>
JavaScript
(function($) {
var privateFunction = function() {
// code here
}
var methods = {
init: function(options) {
// Repeat over each element in selector
return this.each(function() {
var $this = $(this);
// Attempt to grab saved settings, if they don't exist we'll get "undefined".
var settings = $this.data('doughnutPie');
// If we could't grab settings, create them from defaults and passed options
if(typeof(settings) == 'undefined') {
var defaults = {
propertyName: 'value',
onSomeEvent: function() {}
}
settings = $.extend({}, defaults, options);
// Save our newly created settings
$this.data('doughnutPie', settings);
} else {
// We got settings, merge our passed options in with them (optional)
settings = $.extend({}, settings, options);
// If you wish to save options passed each time, add:
// $this.data('doughnutPie', settings);
}
// run code here
methods.setup(this, options);
});
},
destroy: function(options) {
// Repeat over each element in selector
return $(this).each(function() {
var $this = $(this);
// run code here
// Remove settings data when deallocating our plugin
$this.removeData('doughnutPie');
});
},
transitions: function(options) {
// Repeat over each element in selector
return $(this).each(function() {
var $this = $(this);
// run code here
methods.update(this, options);
});
},
setup: function(obj, options){
//setColors
this.currentPieData = options.data;
var setColors = options.specs.colors;
this.isInit = true;
this.homegrownparent = obj.id;
this.setMaxObj();
var w = options.specs.w;
var h =...