Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
!node_modules/canvas.js

bundle.js
/.vs
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ __Arguments__

- `legend` - A boolean used to determine whether a legend should be generated. Defaults to `true`.

- `wrapHtml` - A boolean used to determine whether a `<div>` wrapping the SVG should be generated. Defaults to `true`.

- A pure SVG will be generated if set both `legend` and `wrapHtml` to `false`.


- `data` - An object containing data used to generate the chart. The structure of this object depends on chart `type`. Please refer to the [Chartist Api Documentation](http://gionkunz.github.io/chartist-js/api-documentation.html) for complete details.

Expand Down
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ const generate = R.curryN(3, co.wrap(function * (type, options, data) {
// process options
options = is.function(options) ? options(Chartist) : options;
if (is.not.json(options)) throw new TypeError('options must be an object or a function that returns an object.');
options = Ru.defaults({ legend: true }, options);
options = Ru.defaults({ legend: true, wrapHtml: true }, options);
// create chart
const chart = yield generateChart(Chartist, window, type, options, data);
const legend = options.legend ? generateLegend(data) : '';
return `<div class="ct-chart">${chart}${legend}</div>`;
const legend = options.legend ? generateLegend(data) : '';

return options.wrapHtml ? `<div class="ct-chart">${chart}${legend}</div>` : `${chart}${legend}`;
}));

module.exports = generate;