Skip to main content

MkDocs plugin to add charts from data

Project description

Actions Status PyPI - Python Version PyPI PyPI - Downloads GitHub contributors PyPI - License

mkdocs-charts-plugin

MkDocs plugin to create plots from data using the declarative vegalite syntax.

This makes it easier to build reproducible reports.

Installation

Install the plugin using pip3:

pip3 install mkdocs-charts-plugin

Next, add the following lines to your mkdocs.yml:

plugins:
  - search
  - table-reader

extra_javascript:
  - https://cdn.jsdelivr.net/npm/vega@5
  - https://cdn.jsdelivr.net/npm/vega-lite@5
  - https://cdn.jsdelivr.net/npm/vega-embed@6

markdown_extensions:
  - pymdownx.superfences:
      disable_indented_code_blocks: true
      preserve_tabs: true
      custom_fences:
        - name: vegalite
          class: vegalite
          format: !!python/name:mkdocs_charts_plugin.fence_vegalite_custom

If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set.

Usage

You can insert any valid vegalite JSON into a markdown file using:

```vegalite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
      {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
      {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "b", "type": "quantitative"}
  }
}
```

Options

  • vega_width (default is container). When not specified explicitly in the JSON schema, the width to use (see vegalite customizing size). When set to container width will be 100%.
  • vega_theme (default is default). Specify one of the available vegalite themes
  • vega_renderer (default is svg). Specify one of the available vegalite renderers
  • use_data_path (default is True). When True, any relative urls used in the JSON schema are relative to the data_path. When False, relative urls should be relative to the URL of the page.
  • data_path (default is ""). When use_data_path is enabled, the base path relative to the docs/ folder.

More

  • promote the plugin
    • blogpost, twitter
    • plugin wiki
    • refer to it from table-reader
    • add to demo in print-site

Credits

https://github.com/koaning/justcharts https://facelessuser.github.io/pymdown-extensions/extras/mermaid/ https://vega.github.io/vega-lite/docs/config.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs-charts-plugin-0.0.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_charts_plugin-0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-charts-plugin-0.0.1.tar.gz.

File metadata

  • Download URL: mkdocs-charts-plugin-0.0.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for mkdocs-charts-plugin-0.0.1.tar.gz
Algorithm Hash digest
SHA256 eef7d04c4c4943de402414e6ba09d8dd248af1cb9f39c9d08d119c5c815b766f
MD5 9ff9183e1e1d8141a88157ed10db20c9
BLAKE2b-256 9784f7131a0b3e5e268244c77b0e588078e5544a1b2b32680b696ef234365e9c

See more details on using hashes here.

File details

Details for the file mkdocs_charts_plugin-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_charts_plugin-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for mkdocs_charts_plugin-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 feb38b7dc31afc71c04ade32e245f090cb3b275f2bcf0731c6f1caa368e029db
MD5 1bb2f82b1b7b5dfe3b54f061a9b0025d
BLAKE2b-256 8ab956719ea58a7468ba8ffa1fb8ea4fd3110fff9930500b7637375c6f3f6317

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page