ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to use php chartdirector with laravel + blade framework?
Posted by Marco on Jul-15-2018 02:02
I tried to use one of the examples (percentbar.php) but the graphic image does not appear.

Do you have any idea?

Tks!

  Re: How to use php chartdirector with laravel + blade framework?
Posted by Peter Kwan on Jul-16-2018 04:05
Hi Marco,

I have never used lavarel + blade before. Would you mind to inform me how your use the example in lavarel + blade?

If lavarel + blade is used to create a HTML web page, then the normal method to insert an image into a web page is to use an <IMG> tag. It is the same whether it is a static image or a chart image. The code is like:

<img src="/path/to/percentbar.php">

If you are using lavarel + blade to output the chart image to the browser (instead of outputting a HTML web page), you need to know how to use lavarel + blade to output image content (that is content of MIME type "image/png" or similar types).

In PHP, the standard method to output an image is:

header("Content-type: image/png");
print($c->makeChart2(PNG));

Many "frameworks" have their own ways to output content. They may not use header to output the MIME header, and may not use print to output content. You would need to translate the above code to the output method of lavarel + blade.

Note that even if you use lavarel + blade to output the image, you still need to use HTML to insert the image into a web page.

<img src="/path/to/lavarel_page_outputting_image">

Modern browsers support inserting an image itself into a web page (instead of inserting an URL of the image) by using the data protocol. It is like:

<img src="data:image/png;base64,<?php echo base64_encode($c->makeChart2(PNG)); ?>">

Regards
Peter Kwan

  Re: How to use php chartdirector with laravel + blade framework?
Posted by Marco on Jul-16-2018 07:09
Hi Peter,

I tried as you mentioned using the <img> tag and now its worked.

Laravel works with the routes concept.

Thank you!