woocommerce/assets/js/admin/dashboard_sales.min.js

1 line
1.6 KiB
JavaScript
Raw Normal View History

2011-09-16 12:45:46 +00:00
jQuery(function(){function h(n){var l=[];var o=new Date(n.xaxis.min);o.setUTCDate(o.getUTCDate()-((o.getUTCDay()+1)%7));o.setUTCSeconds(0);o.setUTCMinutes(0);o.setUTCHours(0);var m=o.getTime();do{l.push({xaxis:{from:m,to:m+2*24*60*60*1000}});m+=7*24*60*60*1000}while(m<n.xaxis.max);return l}var k=jQuery.parseJSON(params.order_data.replace(/&quot;/g,'"'));var f=k.order_counts;var a=k.order_amounts;for(var c=0;c<f.length;++c){f[c][0]+=60*60*1000}for(var c=0;c<a.length;++c){a[c][0]+=60*60*1000}var g=jQuery("#placeholder");var e=jQuery.plot(g,[{label:"Number of sales",data:f},{label:"Sales amount",data:a,yaxis:2}],{series:{lines:{show:true},points:{show:true}},grid:{show:true,aboveData:false,color:"#ccc",backgroundColor:"#fff",borderWidth:2,borderColor:"#ccc",clickable:false,hoverable:true,markings:h},xaxis:{mode:"time",timeformat:"%d %b",tickLength:1,minTickSize:[1,"day"]},yaxes:[{min:0,tickSize:1,tickDecimals:0},{position:"right",min:0,tickDecimals:2}],colors:["#8a4b75","#47a03e"]});g.resize();function j(d,l,i){jQuery('<div id="tooltip">'+i+"</div>").css({position:"absolute",display:"none",top:l+5,left:d+5,padding:"5px 10px",border:"3px solid #3da5d5",background:"#288ab7"}).appendTo("body").fadeIn(200)}var b=null;jQuery("#placeholder").bind("plothover",function(i,m,d){if(d){if(b!=d.dataIndex){b=d.dataIndex;jQuery("#tooltip").remove();if(d.series.label=="Number of sales"){var l=d.datapoint[1];j(d.pageX,d.pageY,d.series.label+" - "+l)}else{var l=d.datapoint[1].toFixed(2);j(d.pageX,d.pageY,d.series.label+" - "+params.currency_symbol+l)}}}else{jQuery("#tooltip").remove();b=null}})});