0

I use Laravel and Google Chart.

The script of chart is located in file.js, that is connected to page via <script>:

Now array of data look as:

var rawData = [
        [{v: [8, 0, 0], f: '03/02/13'}, 1]];

So, How I can transfer array data from PHP in this JS script in Laravel?

1

1 Answer 1

1

Actually you have a couple options. You can either fetch the data through a get request (API) or you can transform the data from PHP into a javascript object using for an example Laracasts' PHP-Vars-To-Js-Transformer package.
Please see https://github.com/laracasts/PHP-Vars-To-Js-Transformer.

For prototyping you can also inline the javascript into your blade files and then have access to the php-variables like always.

Hope that gets the job done for you :D

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.