panosoft / node-chartist

SVG Charts on the server.
The Unlicense
83 stars 20 forks source link

svg tag enclosed in div tag #22

Open hellznrg opened 6 years ago

hellznrg commented 6 years ago

When I generate a chart, it returns a DIV enclosing a SVG. How can I get node-chartist to give me just the SVG?

Kshitij978 commented 3 years ago

Follow the changes mentioned below.

Capture

const generate = R.curryN(3, co.wrap(function * (type, options, data) {
    const environment = yield chartist.initialize();
    const window = environment.window;
    const Chartist = environment.Chartist;
    // 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);
    // 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>`;
+   return `${chart}${legend}`;
}));