feat(plugins/stargazers): add support for chartist mode (repository) (#849) [skip ci]

This commit is contained in:
Simon Lecoq
2022-02-08 03:23:51 +01:00
committed by GitHub
parent cb1bba87d5
commit f3f8f8b274

View File

@@ -11,12 +11,15 @@
</div>
<% } else { %>
<div class="row margin-bottom">
<section class="column chart">
<section class="column chart chartist">
<h3>Total stargazers</h3>
<% if (plugins.stargazers.charts) { %>
<%- plugins.stargazers.charts[0] %>
<% } else { %>
<div class="chart-bars">
<% { let previous = null; for (const [date, value] of Object.entries(plugins.stargazers.total.dates)) { const p = 0.05+0.95*(value-plugins.stargazers.total.min)/(plugins.stargazers.total.max-plugins.stargazers.total.min); const [y, m, d] = date.split("-").map(Number) %>
<% { let previous = null; for (const [date, value] of Object.entries(plugins.stargazers.total.dates)) { const p = 0.05+0.95*(value-plugins.stargazers.total.min)/(plugins.stargazers.total.max-plugins.stargazers.total.min || 1); const [y, m, d] = date.split("-").map(Number) %>
<div class="entry">
<span class="value"><%= (value-(previous ?? 0)) ? value : "" %></span>
<span class="value"><%= (value-(previous ?? 0)) ? f(value) : "" %></span>
<div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div>
<%= d %>
<% if ((previous === null)||(d === 1)) { %>
@@ -25,13 +28,17 @@
</div>
<% previous = value } } %>
</div>
<% } %>
</section>
<section class="column chart">
<section class="column chart chartist">
<h3>New stargazers per day</h3>
<% if (plugins.stargazers.charts) { %>
<%- plugins.stargazers.charts[1] %>
<% } else { %>
<div class="chart-bars">
<% { let previous = true; for (const [date, value] of Object.entries(plugins.stargazers.increments.dates)) { const p = value/plugins.stargazers.increments.max; const [y, m, d] = date.split("-").map(Number) %>
<% { let previous = null; for (const [date, value] of Object.entries(plugins.stargazers.increments.dates)) { const p = value/(plugins.stargazers.increments.max || 1); const [y, m, d] = date.split("-").map(Number) %>
<div class="entry">
<span class="value"><%= value != 0 ? value : "" %></span>
<span class="value"><%= value != 0 ? f(value, {sign:true}) : "" %></span>
<div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div>
<%= d %>
<% if ((previous === null)||(d === 1)) { %>
@@ -40,6 +47,7 @@
</div>
<% previous = value } } %>
</div>
<% } %>
</section>
</div>
<% } %>