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,35 +11,43 @@
</div> </div>
<% } else { %> <% } else { %>
<div class="row margin-bottom"> <div class="row margin-bottom">
<section class="column chart"> <section class="column chart chartist">
<h3>Total stargazers</h3> <h3>Total stargazers</h3>
<div class="chart-bars"> <% if (plugins.stargazers.charts) { %>
<% { 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) %> <%- plugins.stargazers.charts[0] %>
<div class="entry"> <% } else { %>
<span class="value"><%= (value-(previous ?? 0)) ? value : "" %></span> <div class="chart-bars">
<div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div> <% { 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) %>
<%= d %> <div class="entry">
<% if ((previous === null)||(d === 1)) { %> <span class="value"><%= (value-(previous ?? 0)) ? f(value) : "" %></span>
<div class="bottom"><%= plugins.stargazers.months[m] %></div> <div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div>
<% } %> <%= d %>
</div> <% if ((previous === null)||(d === 1)) { %>
<% previous = value } } %> <div class="bottom"><%= plugins.stargazers.months[m] %></div>
</div> <% } %>
</div>
<% previous = value } } %>
</div>
<% } %>
</section> </section>
<section class="column chart"> <section class="column chart chartist">
<h3>New stargazers per day</h3> <h3>New stargazers per day</h3>
<div class="chart-bars"> <% if (plugins.stargazers.charts) { %>
<% { 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) %> <%- plugins.stargazers.charts[1] %>
<div class="entry"> <% } else { %>
<span class="value"><%= value != 0 ? value : "" %></span> <div class="chart-bars">
<div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div> <% { 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) %>
<%= d %> <div class="entry">
<% if ((previous === null)||(d === 1)) { %> <span class="value"><%= value != 0 ? f(value, {sign:true}) : "" %></span>
<div class="bottom"><%= plugins.stargazers.months[m] %></div> <div class="bar" style="height: <%= p*50 %>px; background-color: var(--color-calendar-graph-day-L<%= Math.ceil(p/0.25) %>-bg)"></div>
<% } %> <%= d %>
</div> <% if ((previous === null)||(d === 1)) { %>
<% previous = value } } %> <div class="bottom"><%= plugins.stargazers.months[m] %></div>
</div> <% } %>
</div>
<% previous = value } } %>
</div>
<% } %>
</section> </section>
</div> </div>
<% } %> <% } %>