1 line
9.0 KiB
JavaScript
Vendored
1 line
9.0 KiB
JavaScript
Vendored
!function(NioApp){"use strict";let visitorChart={labels:["M","T","W","T","F","S","S"],legend:!1,yAxis:!1,ticksColor:"#9CA3AF",ticksFontSize:11,ticksFontWeight:100,gridColorX:NioApp.Colors.white,gridColorY:NioApp.Colors.white,gridBorderColorX:NioApp.Colors.white,gridBorderColorY:NioApp.Colors.white,datasets:[{borderRadius:10,borderWidth:1,color:"transparent",background:NioApp.hexRGB(NioApp.Colors.info,.3),hoverBackgroundColor:NioApp.Colors.info,label:"Visitors",data:[600,680,470,770,570,810,670]}]},activityChart={labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],legend:!1,lineTension:.4,yAxis:!1,xAxis:!1,datasets:[{label:"Activity",color:NioApp.Colors.success,backgroundGradient:NioApp.Colors.success,pointBackgroundColor:NioApp.Colors.success,borderWidth:2,pointBorderColor:"transparent",pointHoverBackgroundColor:NioApp.Colors.success,data:[120,160,95,105,98,99,167,140,155,267,237,250]}]},totalProfitChart={labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],legend:!1,stacked:!0,ticksColor:"#9CA3AF",ticksFontSize:11,ticksFontWeight:100,maxTicksLimit:20,ticksValue:"k",gridBorderDash:[8,4],gridColorX:NioApp.Colors.white,gridColorY:NioApp.Colors.gray100,gridBorderColorX:NioApp.Colors.white,gridBorderColorY:NioApp.Colors.white,datasets:[{borderRadius:{topLeft:50,topRight:50,bottomLeft:50,bottomRight:50},color:NioApp.Colors.primary,background:NioApp.Colors.primary,border:1,label:"Total Income",data:[120,160,95,105,98,99,167,140,155,267,237,250]},{borderRadius:{topLeft:50,topRight:50,bottomLeft:50,bottomRight:50},color:NioApp.Colors.success,background:NioApp.Colors.success,border:1,label:"Total Profit",data:[110,80,125,55,95,75,90,110,80,125,55,95]},{borderRadius:{topLeft:50,topRight:50,bottomLeft:50,bottomRight:50},color:NioApp.Colors.gray300,background:NioApp.Colors.gray300,border:1,label:"Total Expense",data:[75,90,110,80,125,55,95,75,90,110,80,125]}]},totalRevenueChart={labels:["Jan","Feb","Mar","Apr","May","Jun"],legend:!1,lineTension:.4,yAxis:!1,xAxis:!1,datasets:[{label:"Total",color:NioApp.Colors.primary,backgroundColor:"transparent",borderWidth:4,pointBorderColor:"transparent",pointBackgroundColor:"transparent",pointHoverBackgroundColor:NioApp.Colors.primary,borderCapStyle:"round",data:[12,40,13,130,70,210]}]},salesAnalyticsChart={labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],legend:!1,lineTension:.4,ticksValue:"k",ticksColor:"#9CA3AF",ticksFontSize:11,ticksFontWeight:100,gridBorderDash:[8,4],maxTicksLimit:10,xAxis:!1,gridColorX:NioApp.Colors.white,gridColorY:NioApp.Colors.gray100,gridBorderColorX:NioApp.Colors.white,gridBorderColorY:NioApp.Colors.white,datasets:[{borderWidth:3,color:NioApp.Colors.yellow,backgroundGradient:NioApp.Colors.yellow,pointBorderColor:"transparent",pointBackgroundColor:"transparent",pointHoverBackgroundColor:NioApp.Colors.yellow,label:"Total Sales",data:[40,60,30,65,60,95,90,100,96,120,105,134]},{borderWidth:2,pointBorderColor:"transparent",pointBackgroundColor:"transparent",color:NioApp.Colors.danger,pointHoverBackgroundColor:NioApp.Colors.danger,label:"Total Orders",borderDash:[8,4],data:[70,44,49,78,39,49,39,38,59,80,56,101]}]};NioApp.Chart={tooltip:{rtl:NioApp.State.isRTL,textDirection:NioApp.State.isRTL?"rtl":"ltr",padding:12,boxWidth:10,boxHeight:10,boxPadding:6,backgroundColor:NioApp.Colors.gray100,titleColor:NioApp.Colors.gray900,bodyColor:NioApp.Colors.bodyColor},legend:{rtl:NioApp.State.isRTL,position:"top",labels:{boxWidth:12,boxHeight:12,fontColor:NioApp.Colors.bodyColor,padding:10}},bar:function(selector,data){let elm=document.querySelectorAll(selector);elm.forEach(item=>{let chartId=item.id,setData=void 0===data?eval(chartId):data,chartLegend=void 0!==setData.legend&&setData.legend,chartStacked=void 0!==setData.stacked&&setData.stacked,chartxAxis=void 0===setData.xAxis||setData.xAxis,chartyAxis=void 0===setData.yAxis||setData.yAxis,chartTicksColor=setData.ticksColor,chartTicksFontSize=setData.ticksFontSize,chartTicksFontWeight=setData.ticksFontWeight,chartMaxTicksLimit=setData.maxTicksLimit,chartTicksValue=void 0!==setData.ticksValue&&setData.ticksValue,chartGridColorX=setData.gridColorX,chartGridColorY=setData.gridColorY,chartGridBorderColorX=setData.gridBorderColorX,chartGridBorderColorY=setData.gridBorderColorY,chartGridBorderDash=setData.gridBorderDash,chartBarPercentage=void 0===setData.barPercentage?.1:setData.barPercentage,chartCategoryPercentage=void 0===setData.categoryPercentage?.1:setData.categoryPercentage,chartBarThickness=void 0===setData.barThickness?10:setData.barThickness,chartData=[];for(let t=0;t<setData.datasets.length;t++)chartData.push({label:setData.datasets[t].label,backgroundColor:void 0===setData.datasets[t].background?"transparent":setData.datasets[t].background,borderWidth:void 0===setData.datasets[t].border?1:setData.datasets[t].border,borderColor:setData.datasets[t].color,data:setData.datasets[t].data,borderRadius:void 0===setData.datasets[t].borderRadius?0:setData.datasets[t].borderRadius,borderSkipped:!1,hoverBackgroundColor:setData.datasets[t].hoverBackgroundColor});let canvas=document.getElementById(chartId).getContext("2d"),chart=new Chart(canvas,{type:"bar",data:{labels:setData.labels,datasets:chartData},options:{categoryPercentage:chartCategoryPercentage,barPercentage:chartBarPercentage,barThickness:chartBarThickness,plugins:{legend:{display:chartLegend,...NioApp.Chart.legend},tooltip:{enabled:!0,...NioApp.Chart.tooltip}},responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:chartStacked,display:chartxAxis,grid:{color:chartGridColorX,borderColor:chartGridBorderColorX,borderDash:chartGridBorderDash},ticks:{color:chartTicksColor,beginAtZero:!0,maxTicksLimit:chartMaxTicksLimit,font:{size:chartTicksFontSize,weight:chartTicksFontWeight}}},y:{stacked:chartStacked,display:chartyAxis,grid:{color:chartGridColorY,borderColor:chartGridBorderColorY,borderDash:chartGridBorderDash},ticks:{callback:function(t,a,o){return t+chartTicksValue},color:chartTicksColor,beginAtZero:!0,maxTicksLimit:chartMaxTicksLimit,font:{size:chartTicksFontSize,weight:chartTicksFontWeight}}}}}})})},line:function(selector,data){let elm=document.querySelectorAll(selector);elm.forEach(item=>{let chartId=item.id,setData=void 0===data?eval(chartId):data,chartLegend=void 0!==setData.legend&&setData.legend,chartxAxis=void 0===setData.xAxis||setData.xAxis,chartyAxis=void 0===setData.yAxis||setData.yAxis,chartTicksColor=setData.ticksColor,chartTicksFontSize=setData.ticksFontSize,chartTicksFontWeight=setData.ticksFontWeight,chartMaxTicksLimit=setData.maxTicksLimit,chartTicksValue=void 0!==setData.ticksValue&&setData.ticksValue,chartGridColorX=setData.gridColorX,chartGridColorY=setData.gridColorY,chartGridBorderColorX=setData.gridBorderColorX,chartGridBorderColorY=setData.gridBorderColorY,chartGridBorderDash=setData.gridBorderDash,canvas=document.getElementById(chartId).getContext("2d"),chartData=[];for(let t=0;t<setData.datasets.length;t++){let a=void 0===setData.datasets[t].background?"transparent":setData.datasets[t].background;chartData.push({label:setData.datasets[t].label,tension:setData.lineTension,backgroundColor:setData.datasets[t].backgroundGradient?getGradient(setData.datasets[t].backgroundGradient):a,borderWidth:setData.datasets[t].borderWidth,borderColor:setData.datasets[t].color,pointBorderColor:setData.datasets[t].pointBorderColor,pointBackgroundColor:setData.datasets[t].pointBackgroundColor,pointHoverBackgroundColor:setData.datasets[t].pointHoverBackgroundColor,pointHoverBorderColor:setData.datasets[t].pointHoverBackgroundColor,pointBorderWidth:setData.datasets[t].pointBorderWidth,pointHoverRadius:setData.datasets[t].pointHoverRadius,pointHoverBorderWidth:setData.datasets[t].pointBorderWidth,pointRadius:setData.datasets[t].pointRadius,pointHitRadius:setData.datasets[t].pointHitRadius,fill:!0,data:setData.datasets[t].data,borderDash:setData.datasets[t].borderDash,borderCapStyle:setData.datasets[t].borderCapStyle})}function getGradient(t){let a=canvas.createLinearGradient(0,0,0,canvas.canvas.clientHeight);return a.addColorStop(0,""+NioApp.hexRGB(t,0)),a.addColorStop(.5,""+NioApp.hexRGB(t,.25)),a.addColorStop(1,""+NioApp.hexRGB(t,.1)),a}let chart=new Chart(canvas,{type:"line",data:{labels:setData.labels,datasets:chartData},options:{plugins:{legend:{display:chartLegend,...NioApp.Chart.legend},tooltip:{enabled:!0,...NioApp.Chart.tooltip}},interaction:{mode:"nearest"},responsive:!0,maintainAspectRatio:!1,scales:{y:{display:chartyAxis,grid:{color:chartGridColorY,borderColor:chartGridBorderColorY,borderDash:chartGridBorderDash},ticks:{callback:function(t,a,o){return t+chartTicksValue},color:chartTicksColor,beginAtZero:!0,maxTicksLimit:chartMaxTicksLimit,font:{size:chartTicksFontSize,weight:chartTicksFontWeight}}},x:{display:chartxAxis,grid:{color:chartGridColorX,borderColor:chartGridBorderColorX,borderDash:chartGridBorderDash},ticks:{color:chartTicksColor,beginAtZero:!0,maxTicksLimit:chartMaxTicksLimit,font:{size:chartTicksFontSize,weight:chartTicksFontWeight}}}}}})})}},NioApp.Chart.init=function(){NioApp.Chart.bar('[data-nk-chart="bar"]'),NioApp.Chart.line('[data-nk-chart="line"]')},NioApp.winLoad(NioApp.Chart.init)}(NioApp); |