Use php to dynamically transfer data to highcharts and phphighcharts

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.