37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
<%
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const data = JSON.parse(fs.readFileSync(path.join(metadata.sourceDir, "data.json")));
|
|
|
|
// const maxSessionCount = Math.max(...Object.keys(data.ipCounts));
|
|
// console.log(maxSessionCount)
|
|
const maxSessionCountCount = Math.max(...Object.values(data.ipCounts));
|
|
const logMaxSessionCC = Math.log10(maxSessionCountCount);
|
|
const maxHeight = Math.ceil(logMaxSessionCC);
|
|
const maxHeightValue = Math.pow(10, maxHeight);
|
|
%>
|
|
|
|
|
|
<div id="ip-session-chart" class="chart">
|
|
<div class="chart-left-labels">
|
|
<span style="height: calc(100% / 6);"><%= maxHeightValue.toLocaleString() %></span>
|
|
<span style="height: calc(100% / 6);">100,000</span>
|
|
<span style="height: calc(100% / 6);">10,000</span>
|
|
<span style="height: calc(100% / 6);">1,000</span>
|
|
<span style="height: calc(100% / 6);">100</span>
|
|
<span style="height: calc(100% / 6);">10</span>
|
|
<!-- <span style="height: calc(100% / 6);">1</span> -->
|
|
</div>
|
|
<%
|
|
for (let i = 1; i <= 500; i++) {
|
|
const value = data.ipCounts[`${i}`];
|
|
const heightFrac = 100 * (Math.log10(value) / maxHeight);
|
|
%>
|
|
<div class="chart-column-container">
|
|
<div class="chart-column-spacer" style="height: <%= 100 - heightFrac %>%;"></div>
|
|
<div class="chart-column theme-inverted" style="height: <%= heightFrac %>%;"></div>
|
|
</div>
|
|
<%
|
|
}
|
|
%>
|
|
</div> |