247 lines
6.4 KiB
JavaScript
247 lines
6.4 KiB
JavaScript
/*
|
|
Template Name: Toner eCommerce + Admin HTML Template
|
|
Author: Themesbrand
|
|
Website: https://Themesbrand.com/
|
|
Contact: Themesbrand@gmail.com
|
|
File: Ecommerce Dashboard init js
|
|
*/
|
|
|
|
// get colors array from the string
|
|
function getChartColorsArray(chartId) {
|
|
if (document.getElementById(chartId) !== null) {
|
|
var colors = document.getElementById(chartId).getAttribute("data-colors");
|
|
if (colors) {
|
|
colors = JSON.parse(colors);
|
|
return colors.map(function (value) {
|
|
var newValue = value.replace(" ", "");
|
|
if (newValue.indexOf(",") === -1) {
|
|
var color = getComputedStyle(document.documentElement).getPropertyValue(
|
|
newValue
|
|
);
|
|
if (color) return color;
|
|
else return newValue;
|
|
} else {
|
|
var val = value.split(",");
|
|
if (val.length == 2) {
|
|
var rgbaColor = getComputedStyle(
|
|
document.documentElement
|
|
).getPropertyValue(val[0]);
|
|
rgbaColor = "rgba(" + rgbaColor + "," + val[1] + ")";
|
|
return rgbaColor;
|
|
} else {
|
|
return newValue;
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
console.warn('data-colors atributes not found on', chartId);
|
|
}
|
|
}
|
|
}
|
|
|
|
var linechartcustomerColors = getChartColorsArray("customer_impression_charts");
|
|
if (linechartcustomerColors) {
|
|
var options = {
|
|
series: [{
|
|
name: "Orders",
|
|
type: "area",
|
|
data: [34, 65, 46, 68, 49, 61, 42, 44, 78, 52, 63, 67],
|
|
},
|
|
{
|
|
name: "Earnings",
|
|
type: "bar",
|
|
data: [
|
|
89.25, 98.58, 68.74, 108.87, 77.54, 84.03, 51.24, 28.57, 92.57, 42.36,
|
|
88.51, 36.57,
|
|
],
|
|
},
|
|
{
|
|
name: "Refunds",
|
|
type: "line",
|
|
data: [8, 12, 7, 17, 21, 11, 5, 9, 7, 29, 12, 35],
|
|
},
|
|
],
|
|
chart: {
|
|
height: 310,
|
|
type: "line",
|
|
toolbar: {
|
|
show: false,
|
|
},
|
|
},
|
|
stroke: {
|
|
curve: "straight",
|
|
dashArray: [0, 0, 8],
|
|
width: [0.1, 0, 2],
|
|
},
|
|
fill: {
|
|
opacity: [0.03, 0.9, 1],
|
|
},
|
|
markers: {
|
|
size: [0, 0, 0],
|
|
strokeWidth: 2,
|
|
hover: {
|
|
size: 4,
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: [
|
|
"Jan",
|
|
"Feb",
|
|
"Mar",
|
|
"Apr",
|
|
"May",
|
|
"Jun",
|
|
"Jul",
|
|
"Aug",
|
|
"Sep",
|
|
"Oct",
|
|
"Nov",
|
|
"Dec",
|
|
],
|
|
axisTicks: {
|
|
show: false,
|
|
},
|
|
axisBorder: {
|
|
show: false,
|
|
},
|
|
},
|
|
grid: {
|
|
show: true,
|
|
xaxis: {
|
|
lines: {
|
|
show: true,
|
|
},
|
|
},
|
|
yaxis: {
|
|
lines: {
|
|
show: false,
|
|
},
|
|
},
|
|
padding: {
|
|
top: 0,
|
|
right: -2,
|
|
bottom: 15,
|
|
left: 10,
|
|
},
|
|
},
|
|
legend: {
|
|
show: true,
|
|
horizontalAlign: "center",
|
|
offsetX: 0,
|
|
offsetY: -5,
|
|
markers: {
|
|
width: 9,
|
|
height: 9,
|
|
radius: 6,
|
|
},
|
|
itemMargin: {
|
|
horizontal: 10,
|
|
vertical: 0,
|
|
},
|
|
},
|
|
plotOptions: {
|
|
bar: {
|
|
columnWidth: "20%",
|
|
barHeight: "100%",
|
|
borderRadius: [8],
|
|
},
|
|
},
|
|
colors: linechartcustomerColors,
|
|
tooltip: {
|
|
shared: true,
|
|
y: [{
|
|
formatter: function (y) {
|
|
if (typeof y !== "undefined") {
|
|
return y.toFixed(0);
|
|
}
|
|
return y;
|
|
},
|
|
},
|
|
{
|
|
formatter: function (y) {
|
|
if (typeof y !== "undefined") {
|
|
return "$" + y.toFixed(2) + "k";
|
|
}
|
|
return y;
|
|
},
|
|
},
|
|
{
|
|
formatter: function (y) {
|
|
if (typeof y !== "undefined") {
|
|
return y.toFixed(0) + " Sales";
|
|
}
|
|
return y;
|
|
},
|
|
},
|
|
],
|
|
},
|
|
};
|
|
var chart = new ApexCharts(
|
|
document.querySelector("#customer_impression_charts"),
|
|
options
|
|
);
|
|
chart.render();
|
|
}
|
|
|
|
// Simple Donut Charts
|
|
var chartDonutBasicColors = getChartColorsArray("#store-visits-source");
|
|
if (chartDonutBasicColors) {
|
|
var options = {
|
|
series: [44, 55, 41, 17, 15],
|
|
labels: ["Direct", "Social", "Email", "Other", "Referrals"],
|
|
chart: {
|
|
height: 333,
|
|
type: "donut",
|
|
},
|
|
legend: {
|
|
position: "bottom",
|
|
},
|
|
stroke: {
|
|
show: false
|
|
},
|
|
dataLabels: {
|
|
dropShadow: {
|
|
enabled: false,
|
|
},
|
|
},
|
|
colors: chartDonutBasicColors,
|
|
};
|
|
|
|
var chart = new ApexCharts(
|
|
document.querySelector("#store-visits-source"),
|
|
options
|
|
);
|
|
chart.render();
|
|
}
|
|
|
|
var swiper = new Swiper(".selling-product", {
|
|
slidesPerView: "auto",
|
|
spaceBetween: 15,
|
|
pagination: {
|
|
el: ".swiper-pagination",
|
|
clickable: true,
|
|
},
|
|
autoplay: {
|
|
delay: 2500,
|
|
disableOnInteraction: false,
|
|
},
|
|
});
|
|
|
|
function currentTime() {
|
|
var ampm = new Date().getHours() >= 12 ? "pm" : "am";
|
|
var hour =
|
|
new Date().getHours() > 12 ?
|
|
new Date().getHours() % 12 :
|
|
new Date().getHours();
|
|
var minute =
|
|
new Date().getMinutes() < 10 ?
|
|
"0" + new Date().getMinutes() :
|
|
new Date().getMinutes();
|
|
if (hour < 10) {
|
|
return "0" + hour + ":" + minute + " " + ampm;
|
|
} else {
|
|
return hour + ":" + minute + " " + ampm;
|
|
}
|
|
}
|
|
|
|
setInterval(currentTime, 1000); |