2015-02-01 21:25:09 +00:00
|
|
|
$(function () {
|
|
|
|
|
2018-03-17 17:07:55 +00:00
|
|
|
'use strict'
|
2015-07-25 19:06:16 +00:00
|
|
|
|
2015-02-01 21:25:09 +00:00
|
|
|
/* ChartJS
|
|
|
|
* -------
|
|
|
|
* Here we will create a few charts using ChartJS
|
|
|
|
*/
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
//- MONTHLY SALES CHART -
|
|
|
|
//-----------------------
|
|
|
|
|
|
|
|
// Get context with jQuery - using jQuery's .get() method.
|
2018-03-17 17:07:55 +00:00
|
|
|
var salesChartCanvas = $('#salesChart').get(0).getContext('2d')
|
2015-02-01 21:25:09 +00:00
|
|
|
// This will get the first returned node in the jQuery collection.
|
2018-03-17 17:07:55 +00:00
|
|
|
var salesChart = new Chart(salesChartCanvas)
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
var salesChartData = {
|
2018-03-17 17:07:55 +00:00
|
|
|
labels : ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
2015-02-01 21:25:09 +00:00
|
|
|
datasets: [
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
label : 'Electronics',
|
|
|
|
fillColor : '#dee2e6',
|
|
|
|
strokeColor : '#ced4da',
|
|
|
|
pointColor : '#ced4da',
|
|
|
|
pointStrokeColor : '#c1c7d1',
|
|
|
|
pointHighlightFill : '#fff',
|
|
|
|
pointHighlightStroke: 'rgb(220,220,220)',
|
|
|
|
data : [65, 59, 80, 81, 56, 55, 40]
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
label : 'Digital Goods',
|
|
|
|
fillColor : 'rgba(0, 123, 255, 0.9)',
|
|
|
|
strokeColor : 'rgba(0, 123, 255, 1)',
|
|
|
|
pointColor : '#3b8bba',
|
|
|
|
pointStrokeColor : 'rgba(0, 123, 255, 1)',
|
|
|
|
pointHighlightFill : '#fff',
|
|
|
|
pointHighlightStroke: 'rgba(0, 123, 255, 1)',
|
|
|
|
data : [28, 48, 40, 19, 86, 27, 90]
|
2015-02-01 21:25:09 +00:00
|
|
|
}
|
|
|
|
]
|
2018-03-17 17:07:55 +00:00
|
|
|
}
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
var salesChartOptions = {
|
|
|
|
//Boolean - If we should show the scale at all
|
2018-03-17 17:07:55 +00:00
|
|
|
showScale : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether grid lines are shown across the chart
|
2018-03-17 17:07:55 +00:00
|
|
|
scaleShowGridLines : false,
|
2015-02-01 21:25:09 +00:00
|
|
|
//String - Colour of the grid lines
|
2018-03-17 17:07:55 +00:00
|
|
|
scaleGridLineColor : 'rgba(0,0,0,.05)',
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - Width of the grid lines
|
2018-03-17 17:07:55 +00:00
|
|
|
scaleGridLineWidth : 1,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether to show horizontal lines (except X axis)
|
|
|
|
scaleShowHorizontalLines: true,
|
|
|
|
//Boolean - Whether to show vertical lines (except Y axis)
|
2018-03-17 17:07:55 +00:00
|
|
|
scaleShowVerticalLines : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether the line is curved between points
|
2018-03-17 17:07:55 +00:00
|
|
|
bezierCurve : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - Tension of the bezier curve between points
|
2018-03-17 17:07:55 +00:00
|
|
|
bezierCurveTension : 0.3,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether to show a dot for each point
|
2018-03-17 17:07:55 +00:00
|
|
|
pointDot : false,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - Radius of each point dot in pixels
|
2018-03-17 17:07:55 +00:00
|
|
|
pointDotRadius : 4,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - Pixel width of point dot stroke
|
2018-03-17 17:07:55 +00:00
|
|
|
pointDotStrokeWidth : 1,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point
|
2018-03-17 17:07:55 +00:00
|
|
|
pointHitDetectionRadius : 20,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether to show a stroke for datasets
|
2018-03-17 17:07:55 +00:00
|
|
|
datasetStroke : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - Pixel width of dataset stroke
|
2018-03-17 17:07:55 +00:00
|
|
|
datasetStrokeWidth : 2,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether to fill the dataset with a color
|
2018-03-17 17:07:55 +00:00
|
|
|
datasetFill : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//String - A legend template
|
2018-03-17 17:07:55 +00:00
|
|
|
legendTemplate : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].lineColor%>"></span><%=datasets[i].label%></li><%}%></ul>',
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
|
2018-03-17 17:07:55 +00:00
|
|
|
maintainAspectRatio : false,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - whether to make the chart responsive to window resizing
|
2018-03-17 17:07:55 +00:00
|
|
|
responsive : true
|
|
|
|
}
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
//Create the line chart
|
2018-03-17 17:07:55 +00:00
|
|
|
salesChart.Line(salesChartData, salesChartOptions)
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
//---------------------------
|
|
|
|
//- END MONTHLY SALES CHART -
|
|
|
|
//---------------------------
|
|
|
|
|
|
|
|
//-------------
|
|
|
|
//- PIE CHART -
|
|
|
|
//-------------
|
|
|
|
// Get context with jQuery - using jQuery's .get() method.
|
2018-03-17 17:07:55 +00:00
|
|
|
var pieChartCanvas = $('#pieChart').get(0).getContext('2d')
|
|
|
|
var pieChart = new Chart(pieChartCanvas)
|
|
|
|
var PieData = [
|
2015-02-01 21:25:09 +00:00
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 700,
|
|
|
|
color : '#dc3545',
|
|
|
|
highlight: '#dc3545',
|
|
|
|
label : 'Chrome'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 500,
|
|
|
|
color : '#28a745',
|
|
|
|
highlight: '#28a745',
|
|
|
|
label : 'IE'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 400,
|
|
|
|
color : '#ffc107',
|
|
|
|
highlight: '#ffc107',
|
|
|
|
label : 'FireFox'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 600,
|
|
|
|
color : '#17a2b8',
|
|
|
|
highlight: '#17a2b8',
|
|
|
|
label : 'Safari'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 300,
|
|
|
|
color : '#007bff',
|
|
|
|
highlight: '#007bff',
|
|
|
|
label : 'Opera'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-17 17:07:55 +00:00
|
|
|
value : 100,
|
|
|
|
color : '#6c757d',
|
|
|
|
highlight: '#6c757d',
|
|
|
|
label : 'Navigator'
|
2015-02-01 21:25:09 +00:00
|
|
|
}
|
2018-03-17 17:07:55 +00:00
|
|
|
]
|
|
|
|
var pieOptions = {
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether we should show a stroke on each segment
|
2018-03-17 17:07:55 +00:00
|
|
|
segmentShowStroke : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//String - The colour of each segment stroke
|
2018-03-17 17:07:55 +00:00
|
|
|
segmentStrokeColor : '#fff',
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - The width of each segment stroke
|
2018-03-17 17:07:55 +00:00
|
|
|
segmentStrokeWidth : 1,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Number - The percentage of the chart that we cut out of the middle
|
|
|
|
percentageInnerCutout: 50, // This is 0 for Pie charts
|
|
|
|
//Number - Amount of animation steps
|
2018-03-17 17:07:55 +00:00
|
|
|
animationSteps : 100,
|
2015-02-01 21:25:09 +00:00
|
|
|
//String - Animation easing effect
|
2018-03-17 17:07:55 +00:00
|
|
|
animationEasing : 'easeOutBounce',
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether we animate the rotation of the Doughnut
|
2018-03-17 17:07:55 +00:00
|
|
|
animateRotate : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - Whether we animate scaling the Doughnut from the centre
|
2018-03-17 17:07:55 +00:00
|
|
|
animateScale : false,
|
2015-02-01 21:25:09 +00:00
|
|
|
//Boolean - whether to make the chart responsive to window resizing
|
2018-03-17 17:07:55 +00:00
|
|
|
responsive : true,
|
2015-02-01 21:25:09 +00:00
|
|
|
// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
|
2018-03-17 17:07:55 +00:00
|
|
|
maintainAspectRatio : false,
|
2015-02-01 21:25:09 +00:00
|
|
|
//String - A legend template
|
2018-03-17 17:07:55 +00:00
|
|
|
legendTemplate : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>',
|
2015-02-16 00:46:50 +00:00
|
|
|
//String - A tooltip template
|
2018-03-17 17:07:55 +00:00
|
|
|
tooltipTemplate : '<%=value %> <%=label%> users'
|
|
|
|
}
|
2015-02-01 21:25:09 +00:00
|
|
|
//Create pie or douhnut chart
|
2015-07-12 13:42:55 +00:00
|
|
|
// You can switch between pie and douhnut using the method below.
|
2018-03-17 17:07:55 +00:00
|
|
|
pieChart.Doughnut(PieData, pieOptions)
|
2015-02-01 21:25:09 +00:00
|
|
|
//-----------------
|
|
|
|
//- END PIE CHART -
|
|
|
|
//-----------------
|
|
|
|
|
|
|
|
/* jVector Maps
|
|
|
|
* ------------
|
|
|
|
* Create a world map with markers
|
|
|
|
*/
|
|
|
|
$('#world-map-markers').vectorMap({
|
2018-03-17 17:07:55 +00:00
|
|
|
map : 'world_mill_en',
|
2015-02-01 21:25:09 +00:00
|
|
|
normalizeFunction: 'polynomial',
|
2018-03-17 17:07:55 +00:00
|
|
|
hoverOpacity : 0.7,
|
|
|
|
hoverColor : false,
|
|
|
|
backgroundColor : 'transparent',
|
|
|
|
regionStyle : {
|
|
|
|
initial : {
|
|
|
|
fill : 'rgba(210, 214, 222, 1)',
|
|
|
|
'fill-opacity' : 1,
|
|
|
|
stroke : 'none',
|
|
|
|
'stroke-width' : 0,
|
|
|
|
'stroke-opacity': 1
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
2018-03-17 17:07:55 +00:00
|
|
|
hover : {
|
|
|
|
'fill-opacity': 0.7,
|
|
|
|
cursor : 'pointer'
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
2018-03-17 17:07:55 +00:00
|
|
|
selected : {
|
2015-02-01 21:25:09 +00:00
|
|
|
fill: 'yellow'
|
|
|
|
},
|
2015-09-19 18:05:54 +00:00
|
|
|
selectedHover: {}
|
2015-02-01 21:25:09 +00:00
|
|
|
},
|
2018-03-17 17:07:55 +00:00
|
|
|
markerStyle : {
|
2015-02-01 21:25:09 +00:00
|
|
|
initial: {
|
2018-03-17 17:07:55 +00:00
|
|
|
fill : '#00a65a',
|
2015-02-01 21:25:09 +00:00
|
|
|
stroke: '#111'
|
|
|
|
}
|
|
|
|
},
|
2018-03-17 17:07:55 +00:00
|
|
|
markers : [
|
|
|
|
{
|
|
|
|
latLng: [41.90, 12.45],
|
|
|
|
name : 'Vatican City'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [43.73, 7.41],
|
|
|
|
name : 'Monaco'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [-0.52, 166.93],
|
|
|
|
name : 'Nauru'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [-8.51, 179.21],
|
|
|
|
name : 'Tuvalu'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [43.93, 12.46],
|
|
|
|
name : 'San Marino'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [47.14, 9.52],
|
|
|
|
name : 'Liechtenstein'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [7.11, 171.06],
|
|
|
|
name : 'Marshall Islands'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [17.3, -62.73],
|
|
|
|
name : 'Saint Kitts and Nevis'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [3.2, 73.22],
|
|
|
|
name : 'Maldives'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [35.88, 14.5],
|
|
|
|
name : 'Malta'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [12.05, -61.75],
|
|
|
|
name : 'Grenada'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [13.16, -61.23],
|
|
|
|
name : 'Saint Vincent and the Grenadines'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [13.16, -59.55],
|
|
|
|
name : 'Barbados'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [17.11, -61.85],
|
|
|
|
name : 'Antigua and Barbuda'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [-4.61, 55.45],
|
|
|
|
name : 'Seychelles'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [7.35, 134.46],
|
|
|
|
name : 'Palau'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [42.5, 1.51],
|
|
|
|
name : 'Andorra'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [14.01, -60.98],
|
|
|
|
name : 'Saint Lucia'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [6.91, 158.18],
|
|
|
|
name : 'Federated States of Micronesia'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [1.3, 103.8],
|
|
|
|
name : 'Singapore'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [1.46, 173.03],
|
|
|
|
name : 'Kiribati'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [-21.13, -175.2],
|
|
|
|
name : 'Tonga'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [15.3, -61.38],
|
|
|
|
name : 'Dominica'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [-20.2, 57.5],
|
|
|
|
name : 'Mauritius'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [26.02, 50.55],
|
|
|
|
name : 'Bahrain'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
latLng: [0.33, 6.73],
|
|
|
|
name : 'São Tomé and Príncipe'
|
|
|
|
}
|
2015-02-01 21:25:09 +00:00
|
|
|
]
|
2018-03-17 17:07:55 +00:00
|
|
|
})
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
/* SPARKLINE CHARTS
|
|
|
|
* ----------------
|
|
|
|
* Create a inline charts with spark line
|
|
|
|
*/
|
|
|
|
|
|
|
|
//-----------------
|
|
|
|
//- SPARKLINE BAR -
|
|
|
|
//-----------------
|
|
|
|
$('.sparkbar').each(function () {
|
2018-03-17 17:07:55 +00:00
|
|
|
var $this = $(this)
|
2015-02-01 21:25:09 +00:00
|
|
|
$this.sparkline('html', {
|
2018-03-17 17:07:55 +00:00
|
|
|
type : 'bar',
|
|
|
|
height : $this.data('height') ? $this.data('height') : '30',
|
2015-02-01 21:25:09 +00:00
|
|
|
barColor: $this.data('color')
|
2018-03-17 17:07:55 +00:00
|
|
|
})
|
|
|
|
})
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
//-----------------
|
|
|
|
//- SPARKLINE PIE -
|
|
|
|
//-----------------
|
|
|
|
$('.sparkpie').each(function () {
|
2018-03-17 17:07:55 +00:00
|
|
|
var $this = $(this)
|
2015-02-01 21:25:09 +00:00
|
|
|
$this.sparkline('html', {
|
2018-03-17 17:07:55 +00:00
|
|
|
type : 'pie',
|
|
|
|
height : $this.data('height') ? $this.data('height') : '90',
|
2015-02-01 21:25:09 +00:00
|
|
|
sliceColors: $this.data('color')
|
2018-03-17 17:07:55 +00:00
|
|
|
})
|
|
|
|
})
|
2015-02-01 21:25:09 +00:00
|
|
|
|
|
|
|
//------------------
|
|
|
|
//- SPARKLINE LINE -
|
|
|
|
//------------------
|
|
|
|
$('.sparkline').each(function () {
|
2018-03-17 17:07:55 +00:00
|
|
|
var $this = $(this)
|
2015-02-01 21:25:09 +00:00
|
|
|
$this.sparkline('html', {
|
2018-03-17 17:07:55 +00:00
|
|
|
type : 'line',
|
|
|
|
height : $this.data('height') ? $this.data('height') : '90',
|
|
|
|
width : '100%',
|
2015-02-01 21:25:09 +00:00
|
|
|
lineColor: $this.data('linecolor'),
|
|
|
|
fillColor: $this.data('fillcolor'),
|
|
|
|
spotColor: $this.data('spotcolor')
|
2018-03-17 17:07:55 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|