How PHP dynamically passes data to Highcharts

Source: Internet
Author: User
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.


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.