This paper mainly introduces the knowledge of Dynamic Data transfer from PHP to Highcharts. Has a good reference value.
1: In peacetime work, in the data display, is directly through the background to provide the interface to obtain the JSON string, to display. Today, someone asked how to present the requested dynamic Data locally.
2: In the local environment, I use the wampserver, download Address: http://xiazai.jb51.net/201703/yuanma/WampServer_2.5_ Jb51.rar, browser opens localhost, file is stored in wamp/www directory
3:php code, there is no process to write real-time requests to the database.
<?php $b = Array (' name ' = = ' Beijing ', ' y ' =>20.2), Array (' name ' = ' = ' Shanghai ', ' y ' =>9.6), Array (' name ' = ' "Wuhan ', ' Y ' =>16.6),); $data = Json_encode ($b); Echo ($data);? >
4:html file
<! DOCTYPE html>
5: Here, the introduction of JS file, when it is necessary to display the same JSON string as a different graphic, modify the Type property in the series, while modifying the data column parameters in the Highcharts plotoptions, you can display different graphics, Highcharts can display graphic types.
PHP return Data format: [{"Name": "\u5317\u4eac", "Y": 20.2},{"name": "\u4e0a\u6d77", "Y": 9.6},{"name": "\u6b66\u6c49", "Y": 16.6}], When the requested data needs to be processed, such as when only a subset of the data is needed, the passed array can be processed when the data is requested via get:
The above is the whole content of this article, I hope that everyone's study has helped.