Sherry
Sherry

Reputation: 41

chart drawn by chartist is not shown properly using wkhtmltopdf

12.4 to generate a pdf,charts are drawn by chartist,because chartist is svg based. I can see the chart in browser by html(test-chartist.html right chart).But When I user the command wkhtmltopdf --dpi 300 --page-size A4 test-chartist.html test3.pdf, chart is blank in the test3.pdf. And then I add the flowing js , the result is weirdsize is not right and direction is not right too

Function.prototype.bind = Function.prototype.bind || function (thisp) {
    var fn = this;
    return function () {
        return fn.apply(thisp, arguments);
    };
};

can anybody help me? thank you very much

Upvotes: 2

Views: 503

Answers (1)

Sherry
Sherry

Reputation: 41

OK,I suddenly found out the answer. If I add width and height to the chart's options, everything is fine, as below:

 var options = {
  width: 800,
  height: 150,
  donut: true,
  donutWidth: 30,
 startAngle: 240,
  total: 30,
  showLabel: true,
  animation:false
};

new Chartist.Pie('#mainImg', {
  series: [10,10]
},options);

I hope it can help others.

Upvotes: 2

Related Questions