Create EChart Graph with Radial Tree Model

Before Started

Wanted

I want to create this graph

Question:

How to make it … ?

Answer:

Download HTML Code from ECharts Website

After successful download, open the file and change this code

$.get(ROOT_PATH + 'data/asset/data/flare.json', function (data) {
  myChart.hideLoading();

With

$.get('namaFile.php', function (data) {
    myChart.hideLoading();
    data= JSON.parse(data)

Create PHP File

Create a namaFile.php and insert this code:

<?php

$data=array("name"=>"Makanan", 

"children"=>array(array("name"=>"Gado-gado", 
						 
          "children"=>array(array("name"=>"Sayur", 
										  
          "children"=>array(array("name"=> "Bayam", "value"=>3),
															 
                     array("name"=> "wortel", "value"=>7) )),
	array("name"=>"Gorengan", 
	       "children"=>array(array("name"=> "Tahu", "value"=>3),
			array("name"=> "Kacang", "value"=>20) )),
															
	array("name"=>"Cabe", 
	     "children"=>array(array("name"=> "Merah", "value"=>2)) )
															
	)),
										
	array( "name"=> "Bakso", 
								 
               "children"=>array(array("name"=>"Daging", "value"=> 1), 
										  
                         array("name"=> "Telur", "value"=> 1),
										  
                         )
		),
							
	array( "name"=> "Sate", 
								 
           "children"=>array(array("name"=>"Ayam", 
												 
               "children"=>array(array("name"=> "Agak Gosong", "value"=> 10), 
																	 
                          array("name"=>"Tambah Kecap", "value"=> 3)
																 
               )),
												 
                   array("name"=> "Kambing", "value"=> 10),
												
										 
                 )
	),
						
	array("name"=>"Soto",
									 
           "children"=>array(array("name"=> "Ayam", "value"=> 2),
														 
                     array("name"=> "Daging", "value"=> 1),
														 
                     array("name"=> "Babat", "value"=> 1),
														
		      )
	),
    )
);							
								
		
echo json_encode($data);		
?>

Thanks for reading

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *