-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>CSV to Chart</title> | ||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <!-- Chart.jsを追加 --> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #333; | ||
color: #fff; | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
} | ||
th, td { | ||
padding: 10px; | ||
border: 1px solid #777; | ||
} | ||
th { | ||
background-color: #555; | ||
cursor: pointer; /* カーソルをポインターに設定 */ | ||
} | ||
tr:nth-child(even) { | ||
background-color: #444; | ||
} | ||
tr:hover { | ||
background-color: #555; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<input type="file" id="csvFileInput" accept=".csv" onchange="loadCSVFile(event)"> | ||
<p> | ||
<canvas id="myChart" width="400" height="400"></canvas> <!-- グラフを表示するためのcanvasタグを追加 --> | ||
<table id="dataTable"> | ||
<thead></thead> <!-- theadタグを追加 --> | ||
<tbody></tbody> <!-- tbodyタグを追加 --> | ||
</table> | ||
|
||
<script> | ||
function loadCSVFile(event) { | ||
const input = event.target; | ||
if ('files' in input && input.files.length > 0) { | ||
readFileContent(input.files[0]).then(content => { | ||
parseCSV(content); | ||
}).catch(error => { | ||
console.error(error); // エラー処理を追加 | ||
}); | ||
} | ||
} | ||
|
||
function readFileContent(file) { | ||
const reader = new FileReader(); | ||
return new Promise((resolve, reject) => { | ||
reader.onload = event => resolve(event.target.result); | ||
reader.onerror = error => reject(error); | ||
reader.readAsText(file); | ||
}); | ||
} | ||
|
||
function parseCSV(text) { | ||
const lines = text.split(/\r\n|\n/); | ||
const headers = lines[0].split(','); | ||
headers.push('Current Tier'); // 'Current Tier' ヘッダーを追加 | ||
headers.push('Amount/Staker'); // 'Amount/Staker' ヘッダーを追加 | ||
const table = document.getElementById('dataTable'); | ||
const tbody = table.querySelector('tbody'); // tbodyを選択 | ||
tbody.innerHTML = ''; // tbodyの中身をクリア | ||
const thead = table.createTHead(); | ||
thead.innerHTML = ''; // theadの中身をクリア | ||
const row = thead.insertRow(); | ||
for (const header of headers) { | ||
const th = document.createElement('th'); | ||
th.textContent = header.replace(/"/g, ''); // ヘッダーのダブルコーテーションを削除 | ||
th.addEventListener('click', () => sortTableByColumn(table, headers.indexOf(header))); // onclickからaddEventListenerに変更 | ||
row.appendChild(th); | ||
} | ||
for (let i = 1; i < lines.length; i++) { | ||
if(lines[i].trim() === '') continue; // 空行をスキップ | ||
const cells = lines[i].split(','); | ||
const tr = tbody.insertRow(); // tbodyに行を追加 | ||
for (let j = 0; j < cells.length; j++) { | ||
const td = tr.insertCell(); | ||
let cellText = cells[j]; | ||
// Name 列のダブルコーテーションを削除 | ||
if (headers[j] === 'Name') { | ||
cellText = cellText.replace(/"/g, ''); | ||
} | ||
td.textContent = cellText; | ||
} | ||
// 'Current Tier' カラムの値を設定 | ||
const totalStaked = parseFloat(cells[headers.indexOf('TotalStaked')].replace(/"/g, '')); | ||
let tier = ''; | ||
if (totalStaked >= 200000000) { | ||
tier = 'Tier 1'; | ||
} else if (totalStaked >= 50000000 && totalStaked < 300000000) { | ||
tier = 'Tier 2'; | ||
} else if (totalStaked >= 15000000 && totalStaked < 50000000) { | ||
tier = 'Tier 3'; | ||
} else if (totalStaked >= 1500000 && totalStaked < 15000000) { | ||
tier = 'Tier 4'; | ||
} else if (totalStaked < 1500000) { | ||
tier = 'Tier 99(No Tier)'; | ||
} | ||
const tierTd = tr.insertCell(); | ||
tierTd.textContent = tier; | ||
|
||
// 'Amount/Staker' カラムの値を計算して設定 | ||
const stakers = parseFloat(cells[headers.indexOf('Stakers')].replace(/"/g, '')); | ||
const amountPerStaker = (stakers !== 0) ? (totalStaked / stakers).toFixed(2) : '0'; // 0で割ることを避ける | ||
const amountPerStakerTd = tr.insertCell(); | ||
amountPerStakerTd.textContent = amountPerStaker; | ||
} | ||
} | ||
|
||
function sortTableByColumn(table, columnIndex) { | ||
const tbody = table.querySelector('tbody'); | ||
const rows = Array.from(tbody.rows); | ||
const isAscending = tbody.getAttribute('data-sort-order') === 'asc'; | ||
rows.sort((rowA, rowB) => { | ||
const cellA = rowA.cells[columnIndex].textContent.trim(); | ||
const cellB = rowB.cells[columnIndex].textContent.trim(); | ||
return cellA.localeCompare(cellB, undefined, {numeric: true}) * (isAscending ? -1 : 1); | ||
}); | ||
tbody.setAttribute('data-sort-order', isAscending ? 'desc' : 'asc'); | ||
rows.forEach(row => tbody.appendChild(row)); | ||
} | ||
// parseCSV関数を修正して、円グラフが出力されるようにします | ||
function parseCSV(text) { | ||
const lines = text.split(/\r\n|\n/); | ||
const headers = lines[0].split(','); | ||
headers.push('Current Tier'); // 'Current Tier' ヘッダーを追加 | ||
headers.push('Amount/Staker'); // 'Amount/Staker' ヘッダーを追加 | ||
const table = document.getElementById('dataTable'); | ||
const tbody = table.querySelector('tbody'); // tbodyを選択 | ||
tbody.innerHTML = ''; // tbodyの中身をクリア | ||
const thead = table.createTHead(); | ||
thead.innerHTML = ''; // theadの中身をクリア | ||
const row = thead.insertRow(); | ||
for (const header of headers) { | ||
const th = document.createElement('th'); | ||
th.textContent = header.replace(/"/g, ''); // ヘッダーのダブルコーテーションを削除 | ||
th.addEventListener('click', () => sortTableByColumn(table, headers.indexOf(header))); // onclickからaddEventListenerに変更 | ||
row.appendChild(th); | ||
} | ||
|
||
// カテゴリごとのTotalStakedを集計するためのオブジェクトを追加 | ||
const categoryTotals = {}; | ||
|
||
for (let i = 1; i < lines.length; i++) { | ||
if(lines[i].trim() === '') continue; // 空行をスキップ | ||
const cells = lines[i].split(','); | ||
const tr = tbody.insertRow(); // tbodyに行を追加 | ||
for (let j = 0; j < cells.length; j++) { | ||
const td = tr.insertCell(); | ||
let cellText = cells[j]; | ||
// Name 列のダブルコーテーションを削除 | ||
if (headers[j] === 'Name') { | ||
cellText = cellText.replace(/"/g, ''); | ||
} | ||
td.textContent = cellText; | ||
} | ||
// 'Current Tier' カラムの値を設定 | ||
const totalStaked = parseFloat(cells[headers.indexOf('TotalStaked')].replace(/"/g, '')); | ||
let tier = ''; | ||
if (totalStaked >= 200000000) { | ||
tier = 'Tier 1'; | ||
} else if (totalStaked >= 50000000 && totalStaked < 300000000) { | ||
tier = 'Tier 2'; | ||
} else if (totalStaked >= 15000000 && totalStaked < 50000000) { | ||
tier = 'Tier 3'; | ||
} else if (totalStaked >= 1500000 && totalStaked < 15000000) { | ||
tier = 'Tier 4'; | ||
} else if (totalStaked < 1500000) { | ||
tier = 'Tier 99(No Tier)'; | ||
} | ||
const tierTd = tr.insertCell(); | ||
tierTd.textContent = tier; | ||
|
||
// 'Amount/Staker' カラムの値を計算して設定 | ||
const stakers = parseFloat(cells[headers.indexOf('Stakers')].replace(/"/g, '')); | ||
const amountPerStaker = (stakers !== 0) ? (totalStaked / stakers).toFixed(2) : '0'; // 0で割ることを避ける | ||
const amountPerStakerTd = tr.insertCell(); | ||
amountPerStakerTd.textContent = amountPerStaker; | ||
|
||
// 'Category' カラムの値を取得し、TotalStakedを集計します | ||
const category = cells[headers.indexOf('Category')].replace(/"/g, ''); | ||
if (!categoryTotals[category]) { | ||
categoryTotals[category] = 0; | ||
} | ||
categoryTotals[category] += totalStaked; | ||
} | ||
|
||
// グラフを描画するためにdrawChart関数を呼び出します | ||
drawChart(categoryTotals); | ||
} | ||
|
||
// drawChart関数を追加して、カテゴリごとのTotalStakedを集計し、円グラフを描画します | ||
function drawChart(data) { | ||
const ctx = document.getElementById('myChart').getContext('2d'); | ||
const chart = new Chart(ctx, { | ||
type: 'pie', // グラフの種類を指定 | ||
data: { | ||
labels: Object.keys(data), // カテゴリ名をラベルとして設定 | ||
datasets: [{ | ||
label: 'Total Staked by Category', | ||
data: Object.values(data), // 各カテゴリのTotalStakedの合計値をデータとして設定 | ||
backgroundColor: [ | ||
'rgba(255, 204, 204, 0.2)', // ピンク | ||
'rgba(255, 229, 204, 0.2)', // オレンジ | ||
'rgba(255, 255, 204, 0.2)', // イエロー | ||
'rgba(204, 255, 204, 0.2)', // グリーン | ||
'rgba(204, 255, 255, 0.2)', // ライトブルー | ||
'rgba(204, 204, 255, 0.2)' // パープル | ||
], | ||
borderColor: [ | ||
'rgba(255, 204, 204, 1)', | ||
'rgba(255, 229, 204, 1)', | ||
'rgba(255, 255, 204, 1)', | ||
'rgba(204, 255, 204, 1)', | ||
'rgba(204, 255, 255, 1)', | ||
'rgba(204, 204, 255, 1)' | ||
], | ||
borderWidth: 1 | ||
}] | ||
}, | ||
options: { | ||
responsive: false, // レスポンシブ対応を無効に設定 | ||
legend: { | ||
position: 'right', // 凡例の位置を指定 | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
</script> | ||
|
||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
Address,Name,Category,dAppId,Stakers,Voting,BuildAndEarn,TotalStaked | ||
0x569b344ad6bf087a285f0d415d0066028921d873,ACryptoS,defi,48,10,118098.000,0,118098 | ||
0x74cc66cd0cf57bb2a0f237c89bcf8db92d3721a8,"Age Of Chronos",others,37,171,14525537.847,429091.000,14954628.847 | ||
0x22e1aa6bafb9965523cc33a5bfd2e4d3326a23e4,AirLyft.One,unstoppable-grants,1,149,8656764.467,778437.000,9435201.467 | ||
0x70d264472327B67898c919809A9dc4759B6c0f27,Algem,defi,42,422,169149436.394,1542143.123,170691579.517 | ||
acy3gmgpSdvn6qL1oMKsNJdsZfXKF6uKLT1hjcX73MWUZh3,Archisinal,nft,43,8,68427.299,5000.000,73427.299 | ||
Yi5DLYWxrqzCoGT2xcUM4qLAfRyhN2tqWjMkaEc5MeFkp1j,ArtZero,nft,41,15,66780.000,0,66780 | ||
0xc5b016c5597d298fe9ed22922ce290a048aa5b75,ArthSwap,defi,12,713,29014155.243,428896.614,29443051.857 | ||
0x46c759fc44edb4faa60a76a11898477f9b8d822d,"Astar Blockchain Node Service",utility,70,31,2421930.000,100593.150,2522523.15 | ||
0xA602D021DA61eC4CC44dedBD4e3090A05c97A435,"Astar Core Contributors",tooling,14,2293,333977370.074,7389440.798,341366810.872 | ||
0xd59fC6Bfd9732AB19b03664a45dC29B8421BDA9a,"Astar Degens",nft,11,967,80432489.437,310083.464,80742572.901 | ||
0x8489f4554790F5A103F2B0398537eAEe68B73884,"Astar Dex StarSwap",defi,53,122,2463897.394,79445.415,2543342.809 | ||
0x95f506E72777efCB3C54878bB4160b00Cd11cd84,"Astar Exchange",defi,4,718,8926141.160,1243458.438,10169599.598 | ||
0x992bad137Fc8a50a486B5C6375f581964b4A15FC,"Astar Farm",defi,31,146,27294204.303,0.000,27294204.303 | ||
0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2,"Astar Safe",tooling,16,68,5176580.983,189321.000,5365901.983 | ||
0x7b2152E51130439374672AF463b735a59a47ea85,"Astar Sign Witch",nft,39,156,1737894.987,1589.000,1739483.987 | ||
0xa1019535e6b364523949eaf45f4b17521c1cb074,"Astar Web3 Domains",utility,38,97,1672253.004,8691.000,1680944.004 | ||
0x8b5d62f396Ca3C6cF19803234685e693733f9779,AstarCats,nft,56,80,637841.701,3511.000,641352.701 | ||
0x733ebcC6DF85f8266349DEFD0980f8Ced9B45f35,AstridDAO,defi,64,264,58530190.865,29807.371,58559998.236 | ||
0x03065E84748a9e4a1AEbef15AC89da1Cdf18B202,Avault,defi,22,38,311171.344,0,311171.344 | ||
0x79f916baa98323814d406a67e954cc08ed14a7b8,"Bluez NFT Marketplace",nft,49,67,11650891.280,19407.507,11670298.787 | ||
0xAbF7230E022C9146DF9B4dBeD97e73CF61D612B8,"Bware Labs and Blast API",utility,60,26,464920.896,4000.000,468920.896 | ||
0xa782e40252e557d9e270650243546dbcd879d995,"CANDY GIRL",nft,66,79,7919386.902,37729.000,7957115.902 | ||
0x2fb9a49579073725453981b786a141f748beec67,COSMIZE,others,45,69,1668418.134,0,1668418.134 | ||
0x158a08bcfd8821ba5ed252fd6b13d7013455b2a2,"Ceres Liquidity and Token Lockers",defi,62,27,267504.441,0,267504.441 | ||
0xc3e407a23e02ecf53348d3634f9c2ffe8028d204,ChainChaser,tooling,8,1,0.000,1000.000,1000 | ||
0x101b453a02f961b4e3f0526ecd4c533c3a80d795,"Community Treasury",utility,52,642,102077176.515,912644.127,102989820.642 | ||
0x48b380aa4c3b82c4a88548335b948c8199fa98b1,DeForm,tooling,71,4,0.000,1486843.749,1486843.749 | ||
0xcb1c5353097da08b665c6d4395104afe6374b509,DeStore,nft,0,742,88335466.669,1624145.422,89959612.091 | ||
0x871947d99713455054b8cf129d27d6a37ad6a5b1,Dwellir,utility,9,63,804207.000,18897.500,823104.5 | ||
0x322ab0bad883bde616208f04dab264c86a9b0765,FiDi,utility,2,131,1971631.247,184586.000,2156217.247 | ||
0xdd3983f649fc07e4f25dae90bea84feb92aaad45,Grabber,tooling,25,10,0.000,0.000,0 | ||
0x7672f18994d876a319502f356efea726c4354f39,HEALTHREE,nft,51,279,13233227.194,3302916.356,16536143.55 | ||
0x843f83a60e1b5a3b6437f60439f0398ad788505c,"Heroic Animals",nft,29,30,167898.463,1040.000,168938.463 | ||
0x1d10ceef0c43897aa9d16745bfbdeb49ebaf2b09,"I am xAlice",nft,36,63,1616432.912,2300.000,1618732.912 | ||
0x190dA1B9fA124BD872e9166bA3c7Dd656A11E8F8,InsureDAO,tooling,21,39,228263.000,8999.000,237262 | ||
0x431D5dfF03120AFA4bDf332c61A6e1766eF37BDB,JPYC,defi,24,248,9448575.550,419752.680,9868328.23 | ||
0x8bedbe92a8c139932853eca70cc2586f9aef04ed,KEKKAI,tooling,26,116,1752674.726,1140.000,1753814.726 | ||
0xd843daaaef666b89b013f12741b3a60a4ea87e5c,KIRIFUDA,nft,69,20,317906.364,27284.000,345190.364 | ||
ZSV1GVepvmWFdshMWgczS4zYvmmwEsBjWQjN4WDpUEFRRPy,Lucky,others,17,326,15038373.417,164742.068,15203115.485 | ||
WW4zHhyvhfWbDtt7nushXbp4gEYr7xqXijUZDAGXuLzMAm9,Metadomo,unstoppable-grants,28,47,2836524.000,500.000,2837024 | ||
0xed3e34fbe7b453bc5f7d263f42a2c28fb974d207,Metasky,tooling,47,14,0.000,0.000,0 | ||
0xe785a37c9d5f3377cbb5b8bf7e9db03ddd440449,MoonFit,nft,46,104,3438730.862,56071.873,3494802.735 | ||
0x77ca5df58607a6e57e537f0492bd82e932fee7ac,"NFT Pocket | LOYLE",tooling,34,9,116303.891,500.000,116803.891 | ||
bYLgJmSkWd4S4pTEacF2sNBWFeM4bNerS27FgNVcC9SqRE4,"Neurolanche X Labs",others,5,2233,270781464.714,9425197.727,280206662.441 | ||
0x40B261eD3816f5cd6b548857cf6e78d5CA101bDb,"Nova Wallet",others,35,419,17826675.239,206582.704,18033257.943 | ||
0x48f292E9FDce07bA34217b0AA62E08B62376df3e,OnFinality,utility,20,168,51578574.258,348243.990,51926818.248 | ||
a8SVGV6X5vpZyq85A9mscME9Y7k91LGbhfpB7KjcbtDDUHK,Paras,nft,58,83,2201927.742,5468.545,2207396.287 | ||
0xa99ee26419c8bd8dc776934df2c00649e132d674,Polkaholic.io,utility,61,22,354754.000,10000.000,364754 | ||
0x71abbdbb8cce734263414b9e93afb8250b18bc1a,"Polkasafe Multisig",utility,59,22,18745371.000,1000.000,18746371 | ||
0x862e9ed0e5643dceb579fc31d59c6113ce2790d7,"Prometheus - AI Dex by Balance AI",defi,15,90,1344562.024,11270.500,1355832.524 | ||
0x695cef87e396c9101212c19261728022705d7d69,ProofX,nft,18,22,160938.000,14405.000,175343 | ||
0xb0a74ee0732efb430a0c07dc8a93c104033c6eaa,Protofire,tooling,30,9,440268.155,500.000,440768.155 | ||
0x2b1fe33cb7264dba6331f54012f04133395fde44,RAIR,nft,55,6,0.000,0.000,0 | ||
0xa094e566b61b3c2d88acf7cc15e3dd0fa83f32af,Rarible,nft,72,2,0.000,26999.000,26999 | ||
0xc8b9dbcd14c122764e17ba686ab6448e9d5a0c3d,Sentio,utility,32,17,0.000,0.000,0 | ||
0xcca488aeef7a1d5c633f877453784f025e7cf160,"SiO2 Finance",defi,13,186,52891187.395,614791.919,53505979.314 | ||
0x96fb7eb4419fccf7fd97fc6e39ee1f0541c12508,Singular,nft,6,532,7612991.821,129159.623,7742151.444 | ||
XRhquqkD8yxYNjQWNb3NGZ7ypxpNwxpA6hWAD3QBh4vTFJW,"SkyLab Corporation",unstoppable-grants,57,122,17857546.130,0,17857546.13 | ||
0xfade3a4ecd0a6c7ac9c3ba2ea644a824b7a091bb,"Slash Vision Labs",defi,65,45,401281.912,0,401281.912 | ||
0xc4335B1b76fA6d52877b3046ECA68F6E708a27dd,"Starlay Finance",defi,40,235,14434776.951,62451.000,14497227.951 | ||
0xA0e232D596d6838d39DdDE9b63916B42246BE15e,SushiTop,nft,54,51,587874.298,4251.000,592125.298 | ||
ZdpeaiK28o6DzkdVJardFTZEJTAHKG3HgJn5ZPgsPh345Hg,"Talisman 🪬",utility,33,472,28069752.399,461477.267,28531229.666 | ||
0x51a6ca8dbfea1b19b15037460c14f4b0f80496d7,"The Royal Raffle",nft,23,72,1557962.776,1620.000,1559582.776 | ||
0x4926de018c54511ce2d3be1a0e646725f57155e6,Web3alert,tooling,27,36,3448756.047,119437.935,3568193.982 | ||
0x50a64d05bb8618d8d96a83cbbb12b3044ec3489a,"XY Finance",defi,50,75,1133021.120,0,1133021.12 | ||
0x7BAe21fB8408D534aDfeFcB46371c3576a1D5717,Zenlink,defi,10,164,3483886.155,28282.144,3512168.299 | ||
0x6d47349ce5bae5394730125e55f086d0c863f01f,"apeXchimpz (AXC)",nft,3,408,7588901.599,88445.580,7677347.179 | ||
0x2efbe87a44ac19b6ec50d26218e6d05f2a1a28de,beyondClub,nft,7,60,713153.127,6949.000,720102.127 | ||
0x4271bd392c0ea7a668025a29287ae8be4efd865e,mooon,nft,63,69,3565054.025,3000.000,3568054.025 | ||
0xa5efb5bF75BbB607DC243707A83F2AF5ED4E9813,tofuNFT,nft,67,170,7235848.509,45283.462,7281131.971 |