Files
admin_hura_8/template/javascript/homepage.html

282 lines
8.9 KiB
HTML
Raw Normal View History

2024-01-24 11:49:22 +07:00
<script>
2025-11-20 13:10:28 +07:00
const initCustomerAcquisitionChart = () => {
const chartOptions = {
chart: {
height: 356,
sparkline: {
enabled: false,
},
toolbar: {
show: false,
},
zoom: {
enabled: false,
},
background: "transparent",
},
forecastDataPoints: {
count: 2,
dashArray: [6, 4],
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
grid: {
2024-01-24 11:49:22 +07:00
show: false,
},
2025-11-20 13:10:28 +07:00
yaxis: {
2024-01-24 11:49:22 +07:00
show: false,
2025-11-20 13:10:28 +07:00
min: 125,
max: 181,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
xaxis: {
categories: Array.from({ length: 15 }, (_, index) => index + 1),
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
tooltip: {
y: {
formatter: (val) => val.toString(),
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
stroke: {
curve: "stepline",
width: [2, 1.5],
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
colors: ["#167bff", "rgba(150,150,150,0.3)"],
series: [
{
name: "Customer",
data: [144, 150, 146, 154, 150, 155, 160, 155, 140, 155, 160, 180, 170, 165, 165],
},
{
name: "Advertise",
data: [140, 142, 142, 140, 146, 148, 150, 136, 130, 133, 145, 148, 158, 150, 150],
},
2024-01-24 11:49:22 +07:00
],
2025-11-20 13:10:28 +07:00
}
2024-01-24 11:49:22 +07:00
2025-11-20 13:10:28 +07:00
if (document.getElementById("customer-acquisition-chart")) {
new ApexCharts(document.getElementById("customer-acquisition-chart"), chartOptions).render()
}
2024-01-24 11:49:22 +07:00
}
2025-11-20 13:10:28 +07:00
const initRevenueStatisticsChart = () => {
const chartOptions = {
chart: {
height: 288,
type: "bar",
stacked: true,
background: "transparent",
toolbar: {
show: false,
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
plotOptions: {
bar: {
borderRadius: 8,
borderRadiusApplication: "end",
borderRadiusWhenStacked: "last",
colors: {
backgroundBarColors: ["rgba(150,150,150,0.07)"],
backgroundBarRadius: 8,
},
columnWidth: "45%",
barHeight: "100%",
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
dataLabels: {
enabled: false,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
colors: ["#ff8b4b", "#6c74f8"],
legend: {
show: true,
horizontalAlign: "center",
offsetX: 0,
offsetY: 6,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
series: [
{
name: "Orders",
data: [10, 12, 14, 16, 18, 20, 14, 16, 24, 12],
},
{
name: "Revenue",
data: [15, 24, 21, 28, 30, 40, 22, 32, 48, 20],
},
],
xaxis: {
categories: [
new Date("1/1/2016"),
new Date("1/1/2017"),
new Date("1/1/2018"),
new Date("1/1/2019"),
new Date("1/1/2020"),
new Date("1/1/2021"),
new Date("1/1/2022"),
new Date("1/1/2023"),
new Date("1/1/2024"),
new Date("1/1/2025"),
],
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
labels: {
formatter: (val) => {
return new Date(val).getFullYear().toString()
},
2024-01-24 11:49:22 +07:00
},
},
2025-11-20 13:10:28 +07:00
yaxis: {
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
labels: {
show: false,
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
tooltip: {
enabled: true,
shared: true,
intersect: false,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
grid: {
2024-01-24 11:49:22 +07:00
show: false,
},
2025-11-20 13:10:28 +07:00
responsive: [
{
breakpoint: 450,
options: {
plotOptions: {
bar: {
borderRadius: 4,
},
},
xaxis: {
tickAmount: 3,
},
},
},
],
}
2024-01-24 11:49:22 +07:00
2025-11-20 13:10:28 +07:00
if (document.getElementById("revenue-statics-chart")) {
new ApexCharts(document.getElementById("revenue-statics-chart"), chartOptions).render()
}
2024-01-24 11:49:22 +07:00
}
2025-11-20 13:10:28 +07:00
const initGlobalSalesChart = () => {
const data = [
{
name: "Turkey",
orders: 9,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
{
name: "India",
orders: 12,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
{
name: "Canada",
orders: 13,
},
{
name: "US",
orders: 16,
},
{
name: "Netherlands",
orders: 14,
},
{
name: "Italy",
orders: 17,
},
{
name: "Other",
orders: 19,
},
]
const chartOptions = {
chart: {
height: 344,
type: "bar",
parentHeightOffset: 0,
background: "transparent",
toolbar: {
show: false,
2024-01-24 11:49:22 +07:00
},
},
2025-11-20 13:10:28 +07:00
plotOptions: {
bar: {
horizontal: true,
borderRadius: 4,
distributed: true,
borderRadiusApplication: "end",
2024-01-24 11:49:22 +07:00
},
},
dataLabels: {
2025-11-20 13:10:28 +07:00
enabled: true,
textAnchor: "start",
style: {
colors: ["#fff"],
},
formatter: function (val, opt) {
return opt.w.globals.labels[opt.dataPointIndex] + ": " + val
},
offsetX: -10,
dropShadow: {
enabled: false,
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
series: [
{
data: data.map((country) => country.orders),
},
],
2024-01-24 11:49:22 +07:00
legend: {
2025-11-20 13:10:28 +07:00
show: false,
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
stroke: {
width: 0,
colors: ["#fff"],
2024-01-24 11:49:22 +07:00
},
xaxis: {
2025-11-20 13:10:28 +07:00
categories: data.map((country) => country.name),
},
yaxis: {
2024-01-24 11:49:22 +07:00
labels: {
show: false,
},
2025-11-20 13:10:28 +07:00
},
grid: {
show: false,
},
tooltip: {
theme: "dark",
x: {
2024-01-24 11:49:22 +07:00
show: false,
},
2025-11-20 13:10:28 +07:00
y: {
formatter: (val) => `${val}%`,
},
2024-01-24 11:49:22 +07:00
},
2025-11-20 13:10:28 +07:00
colors: ["#7179ff", "#4bcd89", "#ff6c88", "#5cb7ff", "#9071ff", "#ff5892", "#ff8b4b"],
2024-01-24 11:49:22 +07:00
}
2025-11-20 13:10:28 +07:00
if (document.getElementById("global-sales-chart")) {
new ApexCharts(document.getElementById("global-sales-chart"), chartOptions).render()
2024-01-24 11:49:22 +07:00
}
}
2025-11-20 13:10:28 +07:00
document.addEventListener("DOMContentLoaded", () => {
initCustomerAcquisitionChart()
initRevenueStatisticsChart()
initGlobalSalesChart()
})
2024-01-24 11:49:22 +07:00
</script>