191 lines
4.2 KiB
JavaScript
191 lines
4.2 KiB
JavaScript
|
|
/**
|
|
* Theme: Zircos Admin Template
|
|
* Author: Coderthemes
|
|
* Dashboard 2
|
|
*/
|
|
|
|
! function($) {
|
|
"use strict";
|
|
|
|
var FlotChart = function() {
|
|
this.$body = $("body")
|
|
this.$realData = []
|
|
};
|
|
|
|
//creates plot graph
|
|
FlotChart.prototype.createPlotGraph = function(selector, data1, data2, data3, labels, colors, borderColor, bgColor) {
|
|
//shows tooltip
|
|
function showTooltip(x, y, contents) {
|
|
$('<div id="tooltip" class="tooltipflot">' + contents + '</div>').css({
|
|
position : 'absolute',
|
|
top : y + 5,
|
|
left : x + 5
|
|
}).appendTo("body").fadeIn(200);
|
|
}
|
|
|
|
|
|
$.plot($(selector), [{
|
|
data : data1,
|
|
label : labels[0],
|
|
color : colors[0]
|
|
}, {
|
|
data : data2,
|
|
label : labels[1],
|
|
color : colors[1]
|
|
},{
|
|
data : data3,
|
|
label : labels[2],
|
|
color : colors[2]
|
|
}], {
|
|
series : {
|
|
lines : {
|
|
show : true,
|
|
fill : true,
|
|
lineWidth : 2,
|
|
fillColor : {
|
|
colors : [{
|
|
opacity : 0
|
|
}, {
|
|
opacity : 0.5
|
|
},{
|
|
opacity : 0.6
|
|
}]
|
|
}
|
|
},
|
|
points : {
|
|
show : false
|
|
},
|
|
shadowSize : 0
|
|
},
|
|
|
|
grid : {
|
|
hoverable : true,
|
|
clickable : true,
|
|
borderColor : borderColor,
|
|
tickColor : "#f9f9f9",
|
|
borderWidth : 1,
|
|
labelMargin : 10,
|
|
backgroundColor : bgColor
|
|
},
|
|
legend : {
|
|
position : "ne",
|
|
margin : [0, -24],
|
|
noColumns : 0,
|
|
labelBoxBorderColor : null,
|
|
labelFormatter : function(label, series) {
|
|
// just add some space to labes
|
|
return '' + label + ' ';
|
|
},
|
|
width : 30,
|
|
height : 2
|
|
},
|
|
yaxis : {
|
|
axisLabel: "Daily Visits",
|
|
tickColor : '#f5f5f5',
|
|
font : {
|
|
color : '#bdbdbd'
|
|
}
|
|
},
|
|
xaxis : {
|
|
axisLabel: "Last Days",
|
|
tickColor : '#f5f5f5',
|
|
font : {
|
|
color : '#bdbdbd'
|
|
}
|
|
},
|
|
tooltip : true,
|
|
tooltipOpts : {
|
|
content : '%s: Value of %x is %y',
|
|
shifts : {
|
|
x : -60,
|
|
y : 25
|
|
},
|
|
defaultTheme : false
|
|
}
|
|
});
|
|
},
|
|
//end plot graph
|
|
|
|
|
|
|
|
|
|
//creates Donut Chart
|
|
FlotChart.prototype.createDonutGraph = function(selector, labels, datas, colors) {
|
|
var data = [{
|
|
label : labels[0],
|
|
data : datas[0]
|
|
}, {
|
|
label : labels[1],
|
|
data : datas[1]
|
|
}, {
|
|
label : labels[2],
|
|
data : datas[2]
|
|
}, {
|
|
label : labels[3],
|
|
data : datas[3]
|
|
}];
|
|
var options = {
|
|
series : {
|
|
pie : {
|
|
show : true,
|
|
innerRadius : 0.7
|
|
}
|
|
},
|
|
legend : {
|
|
show : true,
|
|
labelFormatter : function(label, series) {
|
|
return '<div style="font-size:14px;"> ' + label + '</div>'
|
|
},
|
|
labelBoxBorderColor : null,
|
|
margin : 50,
|
|
width : 20,
|
|
padding : 1
|
|
},
|
|
grid : {
|
|
hoverable : true,
|
|
clickable : true
|
|
},
|
|
colors : colors,
|
|
tooltip : true,
|
|
tooltipOpts : {
|
|
content : "%s, %p.0%"
|
|
}
|
|
};
|
|
|
|
$.plot($(selector), data, options);
|
|
},
|
|
|
|
//initializing various charts and components
|
|
FlotChart.prototype.init = function() {
|
|
//plot graph data
|
|
var uploads = [[0, 5], [1, 8], [2, 10], [3, 12], [4, 9], [5, 5], [6, 7],[7, 9], [8, 8], [9, 16], [10, 14], [11, 12], [12, 10]];
|
|
var downloads = [[0, 2], [1, 4], [2, 7], [3, 9], [4, 6], [5, 3], [6, 10],[7, 8], [8, 5], [9, 14], [10, 10], [11, 10], [12, 8]];
|
|
var downloads1 = [[0, 1], [1, 3], [2, 6], [3, 7], [4, 4], [5, 2], [6, 8],[7, 6], [8, 4], [9, 10], [10, 8], [11, 14], [12, 5]];
|
|
var plabels = ["Google", "Yahoo","Facebbok"];
|
|
var pcolors = ['#4bd396', '#f5707a','#188ae2'];
|
|
var borderColor = '#f5f5f5';
|
|
var bgColor = '#fff';
|
|
this.createPlotGraph("#website-stats", uploads, downloads, downloads1, plabels, pcolors, borderColor, bgColor);
|
|
|
|
|
|
//Donut pie graph data
|
|
var donutlabels = ["Series 1", "Series 2", "Series 3", "Series 4"];
|
|
var donutdatas = [35, 20, 10, 20];
|
|
var donutcolors = ['#ff9800', '#8d6e63', "#26a69a", "#7fc1fc"];
|
|
this.createDonutGraph("#donut-chart #donut-chart-container", donutlabels, donutdatas, donutcolors);
|
|
},
|
|
|
|
//init flotchart
|
|
$.FlotChart = new FlotChart, $.FlotChart.Constructor =
|
|
FlotChart
|
|
|
|
}(window.jQuery),
|
|
|
|
//initializing flotchart
|
|
function($) {
|
|
"use strict";
|
|
$.FlotChart.init()
|
|
}(window.jQuery);
|
|
|