Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chemiker committed Jul 12, 2020
0 parents commit d53c0dd
Show file tree
Hide file tree
Showing 13 changed files with 544 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
node_modules/
yarn-error.log
yarn.lock
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
The MIT License (MIT)

Copyright (c) 2020 Alexander Lüken

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This software contains software released under individual licenses:

chartist.js - Copyright (c) 2013 Gion Kunz is released under the MIT license (see file "dist/licenses/LICENSE-CHARTIST")

chartist.js Axistitle plugin - Copyright (c) 2019 Alex Stanbury is released under the MIT license (see file "dist/licenses/LICENSE-CHARTIST-PLUGIN-AXISTITLE")
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# hugo-mod-chartist
**hugo-mod-chartist** is a module for the static site generator [hugo](http://gohugo.io) to implement [chartist.js](https://gionkunz.github.io/chartist-js/index.html).

## Installation

1. Add the module to your `go.mod`. E.g.

```
module github.com/<myself>/<myHugoInstance>
go 1.14
require github.com/chemiker/hugo-mod-chartist latest
```

2. Add the module to the `config.toml` of your Hugo configuration:

```
[module]
[[module.imports]]
path="github.com/chemiker/hugo-mod-chartist"
disabled = false
[[module.imports.mounts]]
source="dist/layouts/partials/"
target="layouts/partials/"
[[module.imports.mounts]]
source="dist/assets/sass/"
target="assets/sass/"
[[module.imports.mounts]]
source="dist/static/js/"
target="static/js/"
```

3. Update the modules of your Hugo configuration by running `hugo mod get -u `

4. Implement the partial template `head-chartist.html` in your website's `<head>`.

## Usage

You can use `<script>` tags to create chartist.js instances as described in the [chartist.js documentation](https://gionkunz.github.io/chartist-js/examples.html).

## Development

It is highly welcome that you fork this repository, file issues or submit pull requests. The module uses [yarn](https://yarnpkg.com) to fetch, modify and merge necessary resources. You can run `yarn install` to fetch all resources and `yarn run gulp make` to run the build scripts.

## License
This project is released under the [MIT license](LICENSE).

It contains software and fonts released under individual licenses:

* *chartist.js* - Copyright (c) 2013 Gion Kunz is released under the MIT license (see file "licenses/LICENSE-CHARTIST")

* *chartist.js Axistitle plugin* - Copyright (c) 2019 Alex Stanbury is released under the MIT license (see file "licenses/LICENSE-CHARTIST-PLUGIN-AXISTITLE")

247 changes: 247 additions & 0 deletions dist/assets/sass/chartist.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/*! Chartist.js
* Copyright © 2019 Gion Kunz
* Free to use under either the WTFPL license or the MIT license.
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-WTFPL
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-MIT
*/
@import "settings/chartist-settings";

@mixin ct-responsive-svg-container($width: 100%, $ratio: $ct-container-ratio) {
display: block;
position: relative;
width: $width;

&:before {
display: block;
float: left;
content: "";
width: 0;
height: 0;
padding-bottom: $ratio * 100%;
}

&:after {
content: "";
display: table;
clear: both;
}

> svg {
display: block;
position: absolute;
top: 0;
left: 0;
}
}

@mixin ct-align-justify($ct-text-align: $ct-text-align, $ct-text-justify: $ct-text-justify) {
-webkit-box-align: $ct-text-align;
-webkit-align-items: $ct-text-align;
-ms-flex-align: $ct-text-align;
align-items: $ct-text-align;
-webkit-box-pack: $ct-text-justify;
-webkit-justify-content: $ct-text-justify;
-ms-flex-pack: $ct-text-justify;
justify-content: $ct-text-justify;
// Fallback to text-align for non-flex browsers
@if($ct-text-justify == 'flex-start') {
text-align: left;
} @else if ($ct-text-justify == 'flex-end') {
text-align: right;
} @else {
text-align: center;
}
}

@mixin ct-flex() {
// Fallback to block
display: block;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}

@mixin ct-chart-label($ct-text-color: $ct-text-color, $ct-text-size: $ct-text-size, $ct-text-line-height: $ct-text-line-height) {
fill: $ct-text-color;
color: $ct-text-color;
font-size: $ct-text-size;
line-height: $ct-text-line-height;
}

@mixin ct-chart-grid($ct-grid-color: $ct-grid-color, $ct-grid-width: $ct-grid-width, $ct-grid-dasharray: $ct-grid-dasharray) {
stroke: $ct-grid-color;
stroke-width: $ct-grid-width;

@if ($ct-grid-dasharray) {
stroke-dasharray: $ct-grid-dasharray;
}
}

@mixin ct-chart-point($ct-point-size: $ct-point-size, $ct-point-shape: $ct-point-shape) {
stroke-width: $ct-point-size;
stroke-linecap: $ct-point-shape;
}

@mixin ct-chart-line($ct-line-width: $ct-line-width, $ct-line-dasharray: $ct-line-dasharray) {
fill: none;
stroke-width: $ct-line-width;

@if ($ct-line-dasharray) {
stroke-dasharray: $ct-line-dasharray;
}
}

@mixin ct-chart-area($ct-area-opacity: $ct-area-opacity) {
stroke: none;
fill-opacity: $ct-area-opacity;
}

@mixin ct-chart-bar($ct-bar-width: $ct-bar-width) {
fill: none;
stroke-width: $ct-bar-width;
}

@mixin ct-chart-donut($ct-donut-width: $ct-donut-width) {
fill: none;
stroke-width: $ct-donut-width;
}

@mixin ct-chart-series-color($color) {
.#{$ct-class-point}, .#{$ct-class-line}, .#{$ct-class-bar}, .#{$ct-class-slice-donut} {
stroke: $color;
}

.#{$ct-class-slice-pie}, .#{$ct-class-slice-donut-solid}, .#{$ct-class-area} {
fill: $color;
}
}

@mixin ct-chart($ct-container-ratio: $ct-container-ratio, $ct-text-color: $ct-text-color, $ct-text-size: $ct-text-size, $ct-grid-color: $ct-grid-color, $ct-grid-width: $ct-grid-width, $ct-grid-dasharray: $ct-grid-dasharray, $ct-point-size: $ct-point-size, $ct-point-shape: $ct-point-shape, $ct-line-width: $ct-line-width, $ct-bar-width: $ct-bar-width, $ct-donut-width: $ct-donut-width, $ct-series-names: $ct-series-names, $ct-series-colors: $ct-series-colors) {

.#{$ct-class-label} {
@include ct-chart-label($ct-text-color, $ct-text-size);
}

.#{$ct-class-chart-line} .#{$ct-class-label},
.#{$ct-class-chart-bar} .#{$ct-class-label} {
@include ct-flex();
}

.#{$ct-class-chart-pie} .#{$ct-class-label},
.#{$ct-class-chart-donut} .#{$ct-class-label} {
dominant-baseline: central;
}

.#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-start} {
@include ct-align-justify(flex-end, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-end} {
@include ct-align-justify(flex-start, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-label}.#{$ct-class-vertical}.#{$ct-class-start} {
@include ct-align-justify(flex-end, flex-end);
// Fallback for browsers that don't support foreignObjects
text-anchor: end;
}

.#{$ct-class-label}.#{$ct-class-vertical}.#{$ct-class-end} {
@include ct-align-justify(flex-end, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-chart-bar} .#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-start} {
@include ct-align-justify(flex-end, center);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-chart-bar} .#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-end} {
@include ct-align-justify(flex-start, center);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-chart-bar}.#{$ct-class-horizontal-bars} .#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-start} {
@include ct-align-justify(flex-end, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-chart-bar}.#{$ct-class-horizontal-bars} .#{$ct-class-label}.#{$ct-class-horizontal}.#{$ct-class-end} {
@include ct-align-justify(flex-start, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: start;
}

.#{$ct-class-chart-bar}.#{$ct-class-horizontal-bars} .#{$ct-class-label}.#{$ct-class-vertical}.#{$ct-class-start} {
//@include ct-chart-label($ct-text-color, $ct-text-size, center, $ct-vertical-text-justify);
@include ct-align-justify(center, flex-end);
// Fallback for browsers that don't support foreignObjects
text-anchor: end;
}

.#{$ct-class-chart-bar}.#{$ct-class-horizontal-bars} .#{$ct-class-label}.#{$ct-class-vertical}.#{$ct-class-end} {
@include ct-align-justify(center, flex-start);
// Fallback for browsers that don't support foreignObjects
text-anchor: end;
}

.#{$ct-class-grid} {
@include ct-chart-grid($ct-grid-color, $ct-grid-width, $ct-grid-dasharray);
}

.#{$ct-class-grid-background} {
fill: $ct-grid-background-fill;
}

.#{$ct-class-point} {
@include ct-chart-point($ct-point-size, $ct-point-shape);
}

.#{$ct-class-line} {
@include ct-chart-line($ct-line-width);
}

.#{$ct-class-area} {
@include ct-chart-area();
}

.#{$ct-class-bar} {
@include ct-chart-bar($ct-bar-width);
}

.#{$ct-class-slice-donut} {
@include ct-chart-donut($ct-donut-width);
}

@if $ct-include-colored-series {
@for $i from 0 to length($ct-series-names) {
.#{$ct-class-series}-#{nth($ct-series-names, $i + 1)} {
$color: nth($ct-series-colors, $i + 1);

@include ct-chart-series-color($color);
}
}
}
}

@if $ct-include-classes {
@include ct-chart();

@if $ct-include-alternative-responsive-containers {
@for $i from 0 to length($ct-scales-names) {
.#{nth($ct-scales-names, $i + 1)} {
@include ct-responsive-svg-container($ratio: nth($ct-scales, $i + 1));
}
}
}
}
6 changes: 6 additions & 0 deletions dist/assets/sass/chartistLicense.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*! Chartist.js
* Copyright © 2019 Gion Kunz
* Free to use under either the WTFPL license or the MIT license.
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-WTFPL
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-MIT
*/
Loading

0 comments on commit d53c0dd

Please sign in to comment.