Echarts Ajax dynamically loading JSON data

Source: Internet
Author: User
Tags php write yii

Background PHP write, to the foreground to prepare JSON format data

 Public Function Actiongetoffline () {$userid = Yii:: $app->user->identity->user_id;      $connection = Yii:: $app->db;      $command = $connection->createcommand ("Select proc_phase_id from Tb_pro where user_id like '% $userid% ';");        $data = $command->queryall ();        Var_dump ($data);      Die ();    $count = Array (0,0,0,0,0,0,0); foreach ($data as $value) {foreach ($value as $value 1) {switch ($value 1) {case 0: $count [0]=            $count [0]+1;        Break            Case 1: $count [1]= $count [1]+1;        Break            Case 3: $count [2]= $count [2]+1;        Break            Case 6: $count [3]= $count [3]+1;        Break            Case: $count [4]= $count [4]+1;        Break            Case: $count [5]= $count [5]+1;        Break            Case: $count [6]= $count [6]+1;        Break      }}} $res = Array (' countdata ' = = $count); //Var_dump ($res);      Die ();    Return Json_encode ($res); }

The JSON data format is as follows: foreground echarts histogram shows that the data is obtained via Ajax:

Finally, the dynamic loading of the data to Echarts is successful, a simple small example:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Echarts Ajax dynamically loading JSON data

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.