FusionCharts Forum: Multiple charts from 1 PHP file, via DataURL method - FusionCharts Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multiple charts from 1 PHP file, via DataURL method Is it possible? How do I do it?

#1 User is offline   Scully 

  • Forum Newbie
  • Group: Members
  • Posts: 1
  • Joined: 22-February 07

Posted 22 February 2007 - 10:40 AM

Hi,

I'm trying to create a page, displaycharts.php, that contains multiple charts. I want all the data for these charts to be created by a single page, chartsdata.php (which will be calling my database) and then to access this data from my displaycharts.php page via the DataURL method.

ie. I would like chartsdata.php to create the XML data for multiple charts, eg, one pie chart telling me the percentages of male and female users, and a bar graph to show a distribution of peoples heights. Then I would need to be able to select these individual charts to render them in different places on the chartsdata.php page.

Is there a way I can do this please? and how would I go about it?

PS. I am trying to do this because I want to limit the number of calls to my database, I will be pulling large amounts of data from the database and then processing this data in PHP to give me the chart data I need. Pulling the same data multiple times (ie. for each chart) from the database will be very inefficient for me and so I am hoping to avoid this.

Thank you in advance,

Scully

0

Other Replies To This Topic

#2 User is offline   Pallav 

  • FusionCharts Team
  • Group: Administrators
  • Posts: 2386
  • Joined: 08-December 06

Posted 24 February 2007 - 03:42 AM

Even if you use the same page to provide data to all charts (by using parameters to judge what data to "spit" out), this page will be called n times (where n is the number of charts).

Let's say you've a page Charts.php, which has 10 charts in it. Now, you create a page ChartData.php, which accepts parameters (like say ChartData.php?dataForChartId=1, for brevity) and then outputs the XML data to the chart that calls it. So, when 10 charts are in the page Charts.php, and each of those chart call ChartData.php, effectively, your page is called 10 times, and as such it would connect to the DB 10 times (unless you cache the recordset or DB objects in some global store).

Other option would be use the client side (AJAX) feature of FusionCharts. In that case, you can send the pertinent data from server to client in JavaScript arrays (see our documentation where we've an example of this in PHP). Now, at client side, you can code JavaScript routines that take this data and form XML at client side using string concatenation. This serves a lot of benefits like:

  • Your data is streamed all-at-once in JS arrays. As such, there are no further calls to server/DB
  • The charts can change data at client side, based on any defined filters. As such, if the user needs to see any view from that data, he can instantly see it without needing a server refresh.
  • You can plot multiple charts out of same data, or multiple views from same data.

Thanks,
Pallav Nadhani
Co-founder & CEO, FusionCharts Team
0

Other Replies To This Topic

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic