Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
denicrizz committed Jun 7, 2024
2 parents 885807a + 541e334 commit b0c5933
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<title>Superstore Landing Page</title>

<!-- Favicons -->
<!-- Faviconsssssssss -->
<link href="img/favicon.ico" rel="icon">

<!-- Google Fonts -->
Expand Down
4 changes: 2 additions & 2 deletions js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ fetch('superstore.json')

// Menghitung total order
const totalOrders = data.length;
document.getElementById('totalOrders').textContent = `${totalOrders} rb`;
document.getElementById('totalOrders').textContent = `${totalOrders} `;

// Menghitung unit terjual
const unitsSold = data.reduce((sum, order) => sum + order['Quantity'], 0);
document.getElementById('unitsSold').textContent = `${unitsSold.toFixed(1)} rb`;
document.getElementById('unitsSold').textContent = `${unitsSold.toFixed(1)} `;

// Menghitung jumlah customer
const totalCustomers = new Set(data.map(order => order['Customer ID'])).size;
Expand Down
35 changes: 17 additions & 18 deletions js/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ fetch('superstore.json')
fetch('superstore.json')
.then(response => response.json())
.then(data => {
var regions = ["200", "400", "600", "800"];
var regions = ["West", "South", "East", "Central"];
var technologyData = [];
var furnitureData = [];
var officeSuppliesData = [];

regions.forEach(region => {
var filteredData = data.filter(item => item["Postal Code"] >= parseInt(region) && item["Postal Code"] < parseInt(region) + 200);
var filteredData = data.filter(item => item.Region === region);
var technologySales = filteredData.filter(item => item.Category === "Technology").reduce((sum, item) => sum + item.Sales, 0);
var furnitureSales = filteredData.filter(item => item.Category === "Furniture").reduce((sum, item) => sum + item.Sales, 0);
var officeSuppliesSales = filteredData.filter(item => item.Category === "Office Supplies").reduce((sum, item) => sum + item.Sales, 0);
Expand All @@ -78,22 +78,16 @@ fetch('superstore.json')
labels: regions,
datasets: [{
label: "Technology",
borderColor: "#5CB3FF",
backgroundColor: "#5CB3FF",
data: technologyData,
fill: false
data: technologyData
}, {
label: "Furniture",
borderColor: "#79BAEC",
backgroundColor: "#79BAEC",
data: furnitureData,
fill: false
data: furnitureData
}, {
label: "Office Supplies",
borderColor: "#82CAFF",
backgroundColor: "#82CAFF",
data: officeSuppliesData,
fill: false
data: officeSuppliesData
}]
};

Expand All @@ -103,18 +97,21 @@ fetch('superstore.json')
display: true,
text: 'Top Sales by Region/Category'
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
scale: {
ticks: {
beginAtZero: true
},
reverse: false
},
animation: {
animateRotate: false,
animateScale: true
}
};

var ctx2 = document.getElementById('myChart2').getContext('2d');
var myChart2 = new Chart(ctx2, {
type: 'bar',
type: 'polarArea',
data: data2,
options: options2
});
Expand All @@ -123,6 +120,8 @@ fetch('superstore.json')
console.error('Error fetching JSON data:', error);
});



// Chart 3
fetch('superstore.json')
.then(response => response.json())
Expand Down

0 comments on commit b0c5933

Please sign in to comment.