Skip to content

Commit

Permalink
updated:decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukundparashar19 committed Nov 16, 2024
1 parent fd152f8 commit f7edf09
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ <h4 class="card-title">Effective fee rate in BPS by transaction size</h4>
<table id="infoTable" class="tablesorter">
<thead>
<tr>
<th>Pleb Rank</th>
<th>Betweenness Rank</th>
<th>Eigenvector Rank</th>
<th>Page Rank</th>
<th>Weighted Degree Rank</th>
<th>Channels Rank</th>
<th>Capacity Rank</th>
<th>Alias</th>
<!-- <th>Pleb Rank</th> -->
<!-- <th>Betweenness Rank</th> -->
<!-- <th>Eigenvector Rank</th> -->
<!-- <th>Page Rank</th> -->
<!-- <th>Weighted Degree Rank</th> -->
<!-- <th>Channels Rank</th> -->
<!-- <th>Capacity Rank</th> -->
<!-- <th>Alias</th> -->
<th>Node Type</th>
<th>Total Capacity</th>
<th>Number of Channels</th>
<!-- <th>Total Capacity</th> -->
<!-- <th>Number of Channels</th> -->
<th>PubKey</th>
</tr>
</thead>
Expand Down
28 changes: 22 additions & 6 deletions js/profile_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ function displayChannelTable(node) {

// Function to display the Channel Size table
function displayChannelSizeTable(node) {
// Helper function to format values
const formatToMillions = (value) => {
if (isNaN(value) || value === null || value === undefined) return 'N/A';
return value >= 1_000_000
? `${Math.floor(value / 1_000_000)}M` // Convert to millions and remove decimals
: Math.floor(value).toLocaleString(); // Display the number without decimals, formatted with commas
};

return `
<div class="table-responsive mt-2">
<table class="table table-sm table-bordered">
Expand All @@ -223,16 +231,19 @@ function displayChannelSizeTable(node) {
</tr>
</thead>
<tbody>
<tr><td>Average Channel Size</td><td>${node.Avg_Channel_Size || 'N/A'}</td></tr>
<tr><td>Max Channel Size</td><td>${node.Max_Channel_Size || 'N/A'}</td></tr>
<tr><td>Median Channel Size</td><td>${node.Median_Channel_Size || 'N/A'}</td></tr>
<tr><td>Min Channel Size</td><td>${node.Min_Channel_Size || 'N/A'}</td></tr>
<tr><td>Mode Channel Size</td><td>${node.Mode_Channel_Size || 'N/A'}</td></tr>
<tr><td>Average Channel Size</td><td>${formatToMillions(node.Avg_Channel_Size)}</td></tr>
<tr><td>Max Channel Size</td><td>${formatToMillions(node.Max_Channel_Size)}</td></tr>
<tr><td>Median Channel Size</td><td>${formatToMillions(node.Median_Channel_Size)}</td></tr>
<tr><td>Min Channel Size</td><td>${formatToMillions(node.Min_Channel_Size)}</td></tr>
<tr><td>Mode Channel Size</td><td>${formatToMillions(node.Mode_Channel_Size)}</td></tr>
</tbody>
</table>
</div>`;
}




// Function to display the Base Fee table
function displayBaseFeeTable(node) {
let html = `
Expand All @@ -248,10 +259,14 @@ function displayBaseFeeTable(node) {

for (const key in node) {
if (key.endsWith('Base_Fee')) {
// Remove decimals using Math.floor or Math.round
let feeValue = node[key];
feeValue = (isNaN(feeValue) || feeValue === null || feeValue === undefined) ? 'N/A' : Math.floor(feeValue);

html += `
<tr>
<td>${key}</td>
<td>${node[key] || 'N/A'}</td>
<td>${feeValue}</td>
</tr>`;
}
}
Expand All @@ -264,6 +279,7 @@ function displayBaseFeeTable(node) {
return html; // Return the HTML for the Base Fee table
}


// Append all tables in a single row
function appendTables(node) {
const tablesRow = `
Expand Down

0 comments on commit f7edf09

Please sign in to comment.