1 Replies - 749 Views - Last Post: 18 May 2013 - 10:27 PM Rate Topic: -----

#1 eva23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-May 13

How to display the chart based on sql query.

Posted 09 May 2013 - 03:06 AM

Hi..

This code below is should be display the chart. well.. it actually has display the chart but not with the correct chart. Not with the correct amount. It should be displaying only 'Sastera & Sains Sosial' and 'Sains' for 'Bekerja' status. Then only 'Sains' for 'Meningkatkan Kemahiran' status, and only 'Sains' for 'Tidak Bekerja' status.

Total of 'Sastera & Sains Sosial' for 'Bekerja' is 1. Total of 'Sains' for 'Bekerja' is 8. Total of 'Sains' for 'Meningkatkan Kemahiran' is 1 and Total of 'Sains' for 'Tidak Bekerja' is 5.
I have trying to correct it but still not working. I do not really know where the real problem is.

And here is the url -> 'http://localhost/rf/demos/mimie.php'

Thank you...


<?php
require "../razorflow.php";

Dashboard::setTitle("Tracer Test 1 -  Dashboard");

$dataSource = new MySQLDataSource('kpt13', 'root', '', 'localhost');
/*$dataSource->setSQLSource('tr_tokens_21639');*/
$dataSource->setSQLSource("tr_tokens_21639
INNER JOIN asm_40statuskerja ON tr_tokens_21639.e_status = asm_40statuskerja.e_kod
INNER JOIN ifm_bidang ON tr_tokens_21639.e_bidang = ifm_bidang.e_id");

/*
#Chart Component
$salesTrend = new ChartComponent();
$salesTrend->setCaption( "Status Responden mengikut Bidang Pengajian", "Sales Trends in {{value}}");
$salesTrend->setDataSource($dataSource);
$salesTrend->setLabelExpression("Status", "asm_40statuskerja.e_keterangan");*/

/*$dataSource = new SQLiteDataSource("databases/northwind.sqlite");
$dataSource->setSQLSource("Products JOIN categories ON categories.CategoryID = Products.CategoryID");*/
$genreChart = new ChartComponent();
$genreChart->setCaption("Chart Component");
$genreChart->setWidth(3);
$genreChart->setYAxis("Total");
$genreChart->setDataSource($dataSource);
$genreChart->setLabelExpression("Status", "asm_40statuskerja.e_keterangan");
$genreChart->addSeries("Sastera & Sains Sosial", "asm_40statuskerja.e_kod", array(
		'aggregateFunction' => "COUNT",
		'condition' => "completed != 'N'",
		//'numberSuffix' => " "
	));
$genreChart->addSeries("Sains", "e_status", array(
'aggregateFunction' => "COUNT",
	'condition' => "completed != 'N'",
));
$genreChart->addSeries("Teknikal", "e_status", array(
'aggregateFunction' => "COUNT",
	'condition' => "completed != 'N'",
));
$genreChart->addSeries("Teknologi Maklumat & Komunikasi", "e_status", array(
'aggregateFunction' => "COUNT",
	'condition' => "completed != 'N'",
));
$genreChart->addSeries("Pendidikan", "e_status", array(
'aggregateFunction' => "COUNT",
	'condition' => "completed != 'N'",
));
$genreChart->setOption('limit', 10);
Dashboard::addComponent($genreChart);

Dashboard::Render();



Is This A Good Question/Topic? 0
  • +

Replies To: How to display the chart based on sql query.

#2 Kruithne  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 99
  • View blog
  • Posts: 442
  • Joined: 28-July 09

Re: How to display the chart based on sql query.

Posted 18 May 2013 - 10:27 PM

Hello,

First of all the URL you have given is not much use because "localhost" is your machine. If I was to navigate to that address I would be querying my own server for /rf/demos/mimie.php which does not exist. In order to let others see that page you would first need to replace "localhost" with your own IP address or configured hostname and then ensure the correct port forwarding has been done to your network to allow such.

Now, regarding the coding problem, could you provide us with some more information? What framework are you using here, what chart generation library are you using? Can you be a little more specific with the error that is occurring as we're unable to see the page?

This post has been edited by Kruithne: 18 May 2013 - 10:27 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1