[Chartjs]-Is there a way to make a view run without having to show the view in the browser in laravel?

0👍

I get what you are asking, you can get the compiled blade template ie: in HTML format using the render() method like the following.

$html = view('graphMaker')->render()

But the problem is that the chart you are trying to make is done using chart.js which is a clientside library. Which means you need a browser to draw the actual chart.

One option is to render the chart from server-side (ie: in PHP itself) using a library (Which you will have to find yourself but one link is here) and pass the rendered html to Mpdf for making the pdf, But the fact is there are no good charting options in the server-side.

The best bet I think is to use the chrome driver to load the HTML and take a screenshot (If I am not wrong you can directly make PDF from it)

Leave a comment