For how to convert echarts chart data and output data in a fixed format.

Source: Internet
Author: User
For how to convert echarts chart data and output data in a fixed format. ECharts has the following two types of data:

Data: ['direct access', 'email marketing ', 'alliance ads', 'Video ads', 'search engine']

Data :[
{Value: 335, name: 'direct access '},
{Value: 310, name: 'directmail '},
{Value: 234, name: 'Alliance ads '},
{Value: 135, name: 'Video ads '},
{Value: 1548, name: 'searchengine '}
]

After I read the corresponding data from the database, how can I convert it to the above two formats ??

Please kindly advise.


Reply to discussion (solution)

I don't understand what you want to express. can I post the data table you want to retrieve?

$ Rs = mysql_query ("select value corresponds to the field name as value, and name corresponds to the field name as name from table ");
While ($ r = mysql_fetch_assoc ($ rs )){
$ D1 [] = $ r [['name'];
$ D2 [] = $ r;
}

$ D1 and $ d2 are the two arrays you want. json_encode is required when returned to echarts.

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.