How to pass data from PHP to JS charting?

Hello, my question is, how EASY it is to construct graphs from given values that are in the database. Data then I can easily from the database to pull out, but in the JS file with graphs to convey in any way.. there is only one method via window['var1'] = '<?php echo $var1?>';
but each variable to throw very expensive, and in the graph data and 10-20 3-5 graphs on the page.
As you can easily pass values from PHP to JS charting?

data: [18, 16, 19, 19, 18, 14, 14, 20, 15, 16, 18, 19, 14, 20, 19, 15, 16, 18, 12, 14, 20, 19, 15, 16, 18 ]

P. S JS file with the charts is in a separate file.
April 4th 20 at 13:03
3 answers
April 4th 20 at 13:05
Knock via JS to the server, get your data and then render graphics.
April 4th 20 at 13:07
Search in Google (with quotes): "REX Tiny templater"
Then, you need to create a json object and pass it to PHP and use.
str = "When <?=$var['m1']?> came from <?=$var['m2']?>, weather <?=$var['m3']?>.";
vars={'m1':'we','m2':'Park','m3':'began to deteriorate'};

console.log(getvars(rex,str)); //Array[3] => ["m1", "m2", "m3"]
console.log(setvars(rex,str,vars)); //When we emerged from the Park, the weather began to deteriorate.

Bonus topic: here.
April 4th 20 at 13:09
Read about AJAX.
The point is that JS "knocking" to PHP, asking him for data.
He says, it is called rest api.
I would advise you to start with get post requests - kavon.Deckow commented on April 4th 20 at 13:12
@kavon.Deckow, get and post requests and there is a REST API. - Destany_Bradt commented on April 4th 20 at 13:15
@Destany_Bradt, you know, I mean that the author should study first what is get/post and then to the rest API. And then Google for the rest API gives immediately about how to build rest about the missing database queries - kavon.Deckow commented on April 4th 20 at 13:18

Find more questions by tags PHPJavaScript