asciidoctor / asciidoctor-chart

A set of Asciidoctor extensions that add a chart block and block macro to AsciiDoc for including charts in your AsciiDoc document.
Other
29 stars 13 forks source link

= Asciidoctor Chart // Aliases: :project-name: Asciidoctor Chart :project-handle: asciidoctor-chart // Variables: :release-version: 1.0.0.alpha.1 :uri-repo: https://github.com/asciidoctor/asciidoctor-chart // Settings: :idprefix: :idseparator: -

image:https://github.com/asciidoctor/asciidoctor-chart/workflows/CI/badge.svg[link=https://github.com/asciidoctor/asciidoctor-chart/actions?query=workflow%3ACI] image:https://img.shields.io/gem/v/asciidoctor-chart?include_prereleases[link=https://rubygems.org/search?query=asciidoctor-chart]

A set of Asciidoctor extensions that adds a chart block and block macro for including charts powered by https://c3js.org/[C3.js], https://gionkunz.github.io/chartist-js/[Chartist], or https://www.chartjs.org/[Chart.js] in your AsciiDoc document.

== Prerequisites

All that's needed is Ruby 2.5 or better (or JRuby 9.2 or better) and a few Ruby gems (including at least Asciidoctor 2.0.0), which we explain how to install in the next section.

To check if you have Ruby available, use the ruby command to query the version installed:

$ ruby -e 'puts RUBY_VERSION'

Make sure this command reports a Ruby version that's at least 2.5. If so, you may proceed.

== Getting Started

You can get {project-name} by <<install-the-published-gem,installing the published gem>>. ifndef::env-site[You can also <<development,run the code from source>> if you want to use a development version or participate in development.]

=== Install the Published Gem

To install {project-name}, first make sure you have satisfied the <<Prerequisites,prerequisites>>. Then, install the gem from RubyGems.org using the following command:

$ gem install asciidoctor-chart

=== Enable the Extension

Assuming all the required gems install properly, you can enable the extension using --require option (or -r for short) from the Asciidoctor CLI:

$ asciidoctor --require asciidoctor-chart my-doc.adoc

=== Usage

Line chart powered by C3.js (default) declared as a literal block:: +

[chart,line] .... January,February,March,April,May,June,July 28,48,40,19,86,27,90 65,59,80,81,56,55,40 ....

+ image::./examples/chart-c3js.png[]

Line chart powered by Chart.js declared as a block macro with a CSV file as target:: +

chart::sample-data.csv[line,engine="chartjs"]

+ image::./examples/chart-chartjs.png[]

For more examples, see {uri-repo}/blob/master/examples/example.adoc[example.adoc].

=== Configuration

[cols="1s,1,3"] |=== |Attribute{nbsp}Name |Value(s)|Description

|c3jsdir |<file|URL> |Overrides c3.js directory, where the following files c3.min.css and c3.min.js are expected. Default is https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.20/.

|chartjsdir |<file|URL> |Overrides chart.js directory, where the following file chart.min.js is expected. Default is https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/.

|chartistdir |<file|URL> |Overrides chartist.js directory, where the following files chartist.min.css and chartist.min.js are expected. Default is https://cdn.jsdelivr.net/chartist.js/0.11.x/.

|d3jsdir |<file|URL> |Overrides d3.js directory, where the following file d3.min.js is expected. Default is https://cdnjs.cloudflare.com/ajax/libs/d3/5.16.0/. |===

== Authors

{project-name} was written by https://github.com/mogztter/[Guillaume Grossetie].

== Copyright

Copyright (C) 2014-present Guillaume Grossetie Free use of this software is granted under the terms of the MIT License.

For the full text of the license, see the <<LICENSE.adoc#,LICENSE>> file.