Skip to content

Commit

Permalink
在开发模式下支持统计已完成和未完成的总数
Browse files Browse the repository at this point in the history
  • Loading branch information
lucumt committed Jun 18, 2024
1 parent dc6b129 commit 748f57a
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions layouts/partials/section_chart.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<!-- 按年统计 -->
{{ $yearAddLineData := slice -}}
{{ $yearAddDraftLineData := slice -}}
{{ $yearAddPieData := slice -}}
{{ $yearTotalData := slice -}}
{{ $yearTotal := 0 -}}
{{ $yearData := slice -}}
{{- range (.Site.RegularPages.GroupByDate "2006" "asc") -}}
{{ $yearValue := (len (where .Pages "Section" "post")) -}}
{{ $yearAddLineData = $yearAddLineData | append $yearValue -}}
{{ $yearFinishValue := (len (where (where .Pages "Section" "post") "Draft" false) ) -}}
{{ $yearAddLineData = $yearAddLineData | append $yearFinishValue -}}

{{ $yearDraftValue := (len (where (where .Pages "Section" "post") "Draft" true) ) -}}
{{ $yearAddDraftLineData = $yearAddDraftLineData | append $yearDraftValue -}}

{{ $yearValue := (len (where .Pages "Section" "post")) -}}
{{ $yearAddPieData = $yearAddPieData | append (dict "name" .Key "y" $yearValue) -}}
{{ $yearTotal = add $yearTotal $yearValue -}}
{{ $yearTotalData = $yearTotalData | append $yearTotal -}}
Expand Down Expand Up @@ -103,6 +109,11 @@
tooltip: {
shared: true
},
plotOptions: {
column: {
stacking: 'normal'
}
},
responsive: {
rules: [{
condition: {
Expand All @@ -117,8 +128,21 @@
}
}]
},
series: [{
name: '按年新增',
series: [
{{ if not (eq hugo.Environment "production") }}
{
name: '按年新增(草稿)',
type: 'column',
color:'#808080',
yAxis: 1,
data: JSON.parse({{ jsonify $yearAddDraftLineData -}}),
tooltip: {
valueSuffix: ' 篇'
}
},
{{ end }}
{
name: {{ if not (eq hugo.Environment "production") }} '按年新增(完成)' {{ else }}'按年新增'{{ end -}},
type: 'column',
color:"#16982b",
yAxis: 1,
Expand Down

0 comments on commit 748f57a

Please sign in to comment.