Use php to dynamically transfer data to highcharts and phphighcharts
1: during normal work, when displaying data, the json string is obtained directly through the interface provided by the background for display. Today, someone asked me how to demonstrate the dynamic data requested locally.
2: Build the environment locally. The WampServer I use,: Bytes
3: php Code. There is no process of writing 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5: Introduce the js file. Modify the type attribute of series when displaying different images for the same json string, at the same time, you can modify the data column parameter plotOptions in highcharts to display different graphs. highcharts can display the 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 request data needs to be processed, for example, if you only need part of the data, you can process the passed array when you request data through get:
The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!