--> Skip to main content

SWF Charts Undefined index HTTPS

Web aplication need nowadays to have charts application. Why we require chart in our application ?. Of course, to visualize data more user-friendly. 

There are many free chart libraries available to solve our problems related data visulization in chart form on web application. It is PHP/SWF Charts as one option. 

How to embed PHP/SWF Charts in PHP file ?

Make sure you have downloaded PHP/SWF Charts in advance and place it anywhere on your web server. In this tutorial, we try make an aplication to display the number of students in each department.

We have data in a table like this :










Based on the table, we create a file tes.php contains code:

<?php
include "charts/charts.php";
 
//the chart's data
$chart [ 'chart_data' ] = array ( array ( "",         "2001", "2002", "2003", "2004" ),
                                  array ( "Informatika", 80,     82,     60,     63  ),
                                  array ( "Elektro    ", 45,     65,     65,     78  ),
                                  array ( "Ekonomi ",    94,     88,    120,     90  )
                                );
 
//send the new data to charts.swf
SendChartData ( $chart );

?>
  
Now, to display data in chart form, we create a file berita.php. It calls tes.php and translate it in chart with dimension 400 x 250 pixels.

<html>
<head>
<title>UPDATE BERITA</title>
<link type="text/css" rel="stylesheet" href="style2.css"/>
</head>
<body>
<div id="wrapper">
 <div id="header">
    <h1 align="center">Diagram Batang
 </h1>  
    </div>          
    <div id="wrapper_konten">
  
  <div id="right_konten">  
  <?php
    include "charts/charts.php";
    echo InsertChart ( "charts/charts.swf", "charts/charts_library", "tes.php", 400, 250 );
        ?>    
        </div>
  <div id="right_konten_bottom">     
        </div>
    </div>
</div>
</body>
</html>
 
The output looks like this:

If you have notice message like this :
Undefined index :HTTPS in Drive:\web_server_address\charts.php on line 17

Open chart.php, comment line 17 and add code below in file chart.php :
$protocol = 'http';
 
Rerun file berita.php, it should be a notice message have been disappeared.

Comment Policy: Silahkan tuliskan komentar Anda yang sesuai dengan topik postingan halaman ini. Komentar yang berisi tautan tidak akan ditampilkan sebelum disetujui.
Buka Komentar
Tutup Komentar