This topic is locked

Graph by passing Unique IDs

3/11/2010 2:52:51 PM
PHPRunner General questions
G
gluckett author

Hi All,

I have a table with 3 columns:

ID, TYPE, COUNT
I want to create a pie chart with the TYPE as the X-Axis and the Count as the content.
How do I dynamically pass the ID so that I can see the chart for that item?

How do I pass more than one IDs so that the pie chart sums the counts and does not repeat the types?
For example:
ID,TYPE,COUNT

1,SALMON,3

1,TUNA,2

1,TROUT,5

2,SALMON,8

2,TUNA,0

2,TROUT,88
I want to pass the ID and get the graph ie.

http://squamish2010.ca/FRASER/FISH_DENSITY_chart.php?ID=1

or

http://squamish2010.ca/FRASER/FISH_DENSITY_chart.php?ID=1,2,3
I want the TUNA to be listed once...not duplicated for each ID.
thanks

gordon

Sergey Kornilov admin 3/11/2010

As a first step you need to group your data by Type. More info:

http://xlinesoft.com/phprunner/docs/using_sql_to_shape_chart_data.htm
Then you can try to mimic search results. To see search parameters in the URL you'll need to change Search form method from POST to GET.

G
gluckett author 3/12/2010

Thanks, the POST to GET Worked like a charm.
But, my SQL query is this:
select

FieldCode,

SUM(FISHCOUNT) AS FISHCOUNT,

ID

FROM dbo.vwFISHCOUNTS_UNPIVOT

GROUP BY FieldCode, ID
I want to dynamically pass the list of selected records "ID"s to the graph and have it sum the totals based on the list.
For example, I would pass a list of unique IDs in a url like this:
mychart.php?value_ID=1,2,3,4
and the graph will always have the same number of categories but they are summed based on the keys I am sending...
thanks

gordon
ps. Just to follow up. What I would really like to do is this:
select

FieldCode,

SUM(FISHCOUNT) AS FISHCOUNT,

FROM dbo.vwFISHCOUNTS_UNPIVOT

WHERE ID in (1,2,33,44)

GROUP BY FieldCode
The issue is that we can't pass the WHERE clause dynamically..



As a first step you need to group your data by Type. More info:

http://xlinesoft.com/phprunner/docs/using_sql_to_shape_chart_data.htm
Then you can try to mimic search results. To see search parameters in the URL you'll need to change Search form method from POST to GET.

G
gluckett author 4/1/2010

Ok, I found a workaround. I am going to use "Open Flash Chart" for any sql queries that require an "IN" list. This was really easy to implement - it just creates JSON... http://teethgrinder.co.uk/open-flash-chart/
for example:

http://squamish2010.ca/FRASER/openchart/pie_fish_densities.php?OBJ_KEYS=2,10,77