woocommerce/assets/js/admin/reports.js

97 lines
2.9 KiB
JavaScript
Raw Normal View History

2013-06-24 16:47:28 +00:00
jQuery(document).ready(function($) {
2013-06-24 16:47:28 +00:00
function showTooltip(x, y, contents) {
jQuery('<div class="chart-tooltip">' + contents + '</div>').css( {
top: y - 16,
left: x + 20
}).appendTo("body").fadeIn(200);
}
2013-06-24 16:47:28 +00:00
var previousPoint = null;
jQuery(".chart-placeholder").bind( "plothover", function (event, pos, item) {
if (item) {
2013-06-25 13:59:20 +00:00
if (previousPoint != item.dataIndex) {
2013-06-24 16:47:28 +00:00
previousPoint = item.dataIndex;
jQuery( ".chart-tooltip" ).remove();
2013-06-27 17:39:55 +00:00
if ( item.series.points.show || item.series.enable_tooltip ) {
2013-06-24 16:47:28 +00:00
2013-06-25 13:59:20 +00:00
var y = item.datapoint[1];
2013-06-24 16:47:28 +00:00
2013-06-25 13:59:20 +00:00
if ( ! item.series.prepend_tooltip )
item.series.prepend_tooltip = item.series.label + ": ";
2013-06-24 16:47:28 +00:00
2013-06-25 13:59:20 +00:00
showTooltip( item.pageX, item.pageY, item.series.prepend_tooltip + y );
2013-06-24 16:47:28 +00:00
}
2013-06-25 13:59:20 +00:00
}
2013-06-24 16:47:28 +00:00
}
else {
jQuery(".chart-tooltip").remove();
previousPoint = null;
}
});
$('.wc_sparkline.bars').each(function() {
2013-06-25 13:59:20 +00:00
var chart_data = $(this).data('sparkline');
var options = {
grid: {
show: false
}
};
// main series
var series = [{
data: chart_data,
color: $(this).data('color'),
bars: { fillColor: $(this).data('color'), fill: true, show: true, lineWidth: 1, barWidth: $(this).data('barwidth'), align: 'center' },
shadowSize: 0
}];
// draw the sparkline
var plot = $.plot( $(this), series, options );
});
$('.wc_sparkline.lines').each(function() {
var chart_data = $(this).data('sparkline');
var options = {
grid: {
show: false
}
};
// main series
var series = [{
data: chart_data,
color: $(this).data('color'),
lines: { fill: false, show: true, lineWidth: 1, align: 'center' },
shadowSize: 0
}];
// draw the sparkline
var plot = $.plot( $(this), series, options );
});
2013-06-24 16:47:28 +00:00
var dates = jQuery( ".range_datepicker" ).datepicker({
defaultDate: "",
dateFormat: "yy-mm-dd",
numberOfMonths: 1,
maxDate: "+0D",
showButtonPanel: true,
showOn: "focus",
buttonImageOnly: true,
onSelect: function( selectedDate ) {
var option = jQuery(this).is('.from') ? "minDate" : "maxDate",
instance = jQuery( this ).data( "datepicker" ),
date = jQuery.datepicker.parseDate(
instance.settings.dateFormat ||
jQuery.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});