forked from shadowfacts/shadowfacts.net
51 lines
1.5 KiB
Plaintext
51 lines
1.5 KiB
Plaintext
<%
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const data = JSON.parse(fs.readFileSync(path.join(metadata.sourceDir, "data.json")));
|
|
|
|
const maxJavaVersionCount = data.javaVersions[Object.keys(data.javaVersions)[0]];
|
|
const javaVersions = Object.keys(data.javaVersions).filter(k => data.javaVersions[k] / maxJavaVersionCount > 0.01);
|
|
const javaVersionWidth = 90 / javaVersions.length;
|
|
|
|
function prettyCount(k) {
|
|
const count = data.javaVersions[k];
|
|
if (count > 1000000) {
|
|
return Math.round(count / 100000) / 10 + "M";
|
|
} else if (count > 1000) {
|
|
return Math.round(count / 1000) + "k"
|
|
}
|
|
}
|
|
%>
|
|
|
|
<div id="java-version-chart" class="chart">
|
|
<%
|
|
for (const k of javaVersions) {
|
|
const percent = Math.round(100 * data.javaVersions[k] / data.total);
|
|
const heightFrac = 100 * data.javaVersions[k] / maxJavaVersionCount;
|
|
if (heightFrac < 1) continue;
|
|
%>
|
|
<div class="chart-column-container" style="width: <%= javaVersionWidth %>%;">
|
|
<div class="chart-column-spacer" style="height: <%= 100 - heightFrac %>%;">
|
|
<% if (heightFrac != 100) { %>
|
|
<span class="chart-column-data-label">
|
|
<%= prettyCount(k) %>
|
|
<br>
|
|
<%= percent %>%
|
|
</span>
|
|
<% } %>
|
|
</div>
|
|
<div class="chart-column theme-inverted" style="height: <%= heightFrac %>%;">
|
|
<% if (heightFrac == 100) { %>
|
|
<span class="chart-column-data-label">
|
|
<%= prettyCount(k) %>
|
|
<br>
|
|
<%= percent %>%
|
|
</span>
|
|
<% } %>
|
|
</div>
|
|
<span class="chart-column-label"><%= k %></span>
|
|
</div>
|
|
<%
|
|
}
|
|
%>
|
|
</div> |