Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a Chart.js component for Hugo. 📈

License

NotificationsYou must be signed in to change notification settings

shen-yu/hugo-chart

Repository files navigation

Awesome

English |中文说明

About

This is not a standalone theme. It is aHugo theme component providing a shortcode:chart to displayChart.js in your Hugo site.

Screenshot

Usage

  1. Add thehugo-chart as a submodule to be able to get upstream changes latergit submodule add https://github.com/Shen-Yu/hugo-chart.git themes/hugo-chart

  2. Addhugo-chart as the left-most element of thetheme list variable in your site's or theme's configuration fileconfig.yaml orconfig.toml. Example, withconfig.yaml:

    theme:["hugo-chart", "my-theme"]

    or, withconfig.toml,

    theme = ["hugo-chart","my-theme"]
  3. In your site, use the shortcode, this way:

    {{<chart [width] [height]>}}// Chartjs options goes here{{</chart>}}
    NameTypeDefaultDescription
    widthnumber100The width of chart, responsive in window (%).
    heightnumber300The height of chart (px).
  4. Note that Chartjs is responsive as default, in order for the above code to correctly resize the chart height, themaintainAspectRatio option must be set tofalse.

Example

{{<chart90200>}}{type: 'bar',data: {labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],datasets: [{label: 'BarChart',data: [12,19,18,16,13,14],backgroundColor: [                'rgba(255,99,132,0.2)',                'rgba(54,162,235,0.2)',                'rgba(255,206,86,0.2)',                'rgba(75,192,192,0.2)',                'rgba(153,102,255,0.2)',                'rgba(255,159,64,0.2)'            ],borderColor: [                'rgba(255,99,132,1)',                'rgba(54,162,235,1)',                'rgba(255,206,86,1)',                'rgba(75,192,192,1)',                'rgba(153,102,255,1)',                'rgba(255,159,64,1)'            ],borderWidth:1        }]    },options: {maintainAspectRatio:false,scales: {yAxes: [{ticks: {beginAtZero:true                }            }]        }    }}{{</chart>}}

Bar chart

License

hugo-chart byEric Shen is underGPL v3 license.

visitors-count

About

a Chart.js component for Hugo. 📈

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp