-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart.njk
More file actions
36 lines (33 loc) · 944 Bytes
/
chart.njk
File metadata and controls
36 lines (33 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
layout: layouts/base.njk
title: Chart
permalink: /chart/
stylesheet: "https://cdn.jsdelivr.net/npm/charts.css@1.1.0/dist/charts.min.css"
description: "This is a chart of the posts written by year."
---
{% set postCounts = collections.posts | byYear %}
{% set maxPostCount = 0 %}
{% for year, count in postCounts %}
{% if count > maxPostCount %}
{% set maxPostCount = count %}
{% endif %}
{% endfor %}
<div id="post-count">
<table class="charts-css bar show-heading show-labels show-primary-axis data-spacing-4 data-center">
<caption>Post Count</caption>
<thead>
<tr>
<th scope="col"> Year </th>
<th scope="col"> Count </th>
</tr>
</thead>
<tbody>
{% for year, count in postCounts %}
<tr>
<th scope="row"> {{ year }}</th>
<td style="--size: calc( {{ count }} / {{ maxPostCount }});"> <span class="data"> {{ count }} </span> </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>