Data for Chart is retrieved from Joomlas MySql Database

Notes:
We will not only access Joomla's local database but retrieve similar data from remote MySql Datenbases. All sites have flashChart installed and are using flashChart's MySql interface.

In this sample two charts are generated. Second chart is not displayed ("hidden") as it has parameter "hide_chart" set. All charts may be displayed by clicking choice in chart menu. Javascripts to be used in "menu" have been created dynamically via parameter "create_script".

  • {flashchart width="600" height="240" data="popup_window" url="php-apps/flashchart/samples/chart_parm02-en.html" title="Click to see flashChart parameters for this sample"}chart01{/flashchart}

Please select choice in chart menu

{flashchart height="400" width="100%" data="database" sql="Select title, hits From jos_content Order By hits Desc Limit 10" create_script="localhost" multibar_color="1" menu="oberquembach.de,oberquembach" type="bar_cylinder" tooltip="#val# Hits" title="Most read at jschmidt-systemberatung.de" x_label_rotate="40" bar_animation="grow-up"}sample006{/flashchart} {flashchart height="400" width="100%" create_script="oberquembach" hide_chart="1" menu="jschmidt-sytemberatung,localhost" data="url" url="http://www.oberquembach.de/index.php?option=com_content&tmpl=getDatafromDB" multibar_color="1" type="bar_cylinder" tooltip="#val# Hits" title="Most read at oberquembach.de" x_label_rotate="40" x_label_truncate="20" bar_animation="fade-in"}sample006{/flashchart} Access to remote MySql Databaes is done with a tiny PHP-Script, which will be triggered for execution via parameter data="url" and "url". It uses flashChart's Version 1.3.0 interfaces (via "flashchart_class.php").

Here you have this PHP-Script - "getDatafromDB.php", which has been installed in directory "../templates/system" on both remote sites:

<?php

defined('_JEXEC') or die('Restricted access');
require_once (JPATH_ROOT . "/plugins/content/flashchart/lib/flashchart_class.php");

$chartdata = new flashChart("myid");
$chartdata->setChartProperty("data", "database");
$chartdata->setChartProperty("sql", "Select title, hits From jos_content Order By hits Desc Limit 10");

echo ( $chartdata->getChartProperty("data") );

?>

Important: If you want to test this sample via copy/paste, ensure that you paste with option "paste as plain text" otherwise imbedded html-codes may invalidate your input.

 

back...
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.