1 line
1.8 KiB
JavaScript
1 line
1.8 KiB
JavaScript
jQuery(function(){function e(e){var t=[],n=new Date(e.xaxis.min);n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+1)%7);n.setUTCSeconds(0);n.setUTCMinutes(0);n.setUTCHours(0);var r=n.getTime();do{t.push({xaxis:{from:r,to:r+1728e5}});r+=6048e5}while(r<e.xaxis.max);return t}function u(e,t,n){jQuery('<div id="tooltip">'+n+"</div>").css({position:"absolute",display:"none",top:t+5,left:e+5,padding:"5px 10px",border:"3px solid #3da5d5",background:"#288ab7"}).appendTo("body").fadeIn(200)}var t=jQuery.parseJSON(params.order_data.replace(/"/g,'"')),n=t.order_counts,r=t.order_amounts;for(var i=0;i<n.length;++i)n[i][0]+=36e5;for(var i=0;i<r.length;++i)r[i][0]+=36e5;var s=jQuery("#placeholder"),o=jQuery.plot(s,[{label:params.number_of_sales,data:n},{label:params.sales_amount,data:r,yaxis:2}],{series:{lines:{show:!0,fill:!0},points:{show:!0}},grid:{show:!0,aboveData:!1,color:"#ccc",backgroundColor:"#fff",borderWidth:2,borderColor:"#ccc",clickable:!1,hoverable:!0,markings:e},xaxis:{mode:"time",timeformat:"%d %b",monthNames:params.i18n_month_names,tickLength:1,minTickSize:[1,"day"]},yaxes:[{min:0,tickSize:10,tickDecimals:0},{position:"right",min:0,tickDecimals:2}],colors:["#8a4b75","#47a03e"],legend:{show:!0,position:"nw"}});s.resize();var a=null;jQuery("#placeholder").bind("plothover",function(e,t,n){if(n){if(a!=n.dataIndex){a=n.dataIndex;jQuery("#tooltip").remove();if(n.series.label==params.number_of_sales){var r=n.datapoint[1];u(n.pageX,n.pageY,params.i18n_sold+": "+r)}else{var r=n.datapoint[1].toFixed(2),i=accounting.formatMoney(r,{symbol:params.currency_format_symbol,decimal:params.currency_format_decimal_sep,thousand:params.currency_format_thousand_sep,precision:params.currency_format_num_decimals,format:params.currency_format});u(n.pageX,n.pageY,params.i18n_earned+": "+i)}}}else{jQuery("#tooltip").remove();a=null}})}); |