Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(shortcodes): add width and height params for echarts shortc… (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored Mar 21, 2020
1 parent aed8734 commit b6ce753
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 0 additions & 2 deletions assets/css/_partial/_single/_echarts.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.echarts {
width: 100%;
height: 30rem;
margin: .5rem 0;
text-align: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,16 @@ The rendered output looks like this:
}
{{< /echarts >}}

The `echarts` shortcode has also the following named parameters:

* **width** *[optional]* (**first** positional parameter)

{{< version 0.2.0 >}} Width of the data visualization, default value is `100%`.

* **height** *[optional]* (**second** positional parameter)

{{< version 0.2.0 >}} Height of the data visualization, default value is `30rem`.

## `mapbox`

{{< version 0.2.0 >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,16 @@ The rendered output looks like this:
}
{{< /echarts >}}

The `echarts` shortcode has also the following named parameters:

* **width** *[optional]* (**first** positional parameter)

{{< version 0.2.0 >}} Width of the data visualization, default value is `100%`.

* **height** *[optional]* (**second** positional parameter)

{{< version 0.2.0 >}} Height of the data visualization, default value is `30rem`.

## `mapbox`

{{< version 0.2.0 >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,16 @@ data = [
}
{{< /echarts >}}

`echarts` shortcode 还有以下命名参数:

* **width** *[可选]* (**第一个**位置参数)

{{< version 0.2.0 >}} 数据可视化的宽度, 默认值是 `100%`.

* **height** *[可选]* (**第二个**位置参数)

{{< version 0.2.0 >}} 数据可视化的高度, 默认值是 `30rem`.

## `mapbox`

{{< version 0.2.0 >}}
Expand Down
4 changes: 3 additions & 1 deletion layouts/shortcodes/echarts.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

{{- $content := .Inner | transform.Unmarshal | jsonify -}}
{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}}
<div class="echarts" id="{{ $id }}"></div>
{{- $width := cond .IsNamedParams (.Get "width") (.Get 0) | default "100%" -}}
{{- $height := cond .IsNamedParams (.Get "height") (.Get 1) | default "30rem" -}}
<div class="echarts" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- $scratch.Set "echarts" true -}}

Large diffs are not rendered by default.

0 comments on commit b6ce753

Please sign in to comment.