How to create Basic Bar Graph or Pie Chart from a database table
Copy link to clipboard
Copied
I have a database table where users have indicated their interests, and I'd like to understand the simplest way to generate a graph of the data.
Most of the data in this survey was gathered in the form of checkboxes, and in the database I entered a "1" if they checked the item, or a "0" if they didn't. So the table might look like this:
field value
apples 1
oranges 0
pineapples 0
bananas 0
dogs 1
cats 0
birds 0
The user above only likes apples.(for fruits) and only likes dogs (for pets)
Is there a simple way for me to display the results for all users in the database (for all fields).
bar and pie charts would be great. I'd like to do this using CF tags in my code.
Thank you
Copy link to clipboard
Copied
What have you tried? Have you tried something that you are having difficulty with?
Have you looked at the cfchart documentation?? cfchart - ColdFusion, English documentation - Adobe Learning Resources / Creating Charts and Graphs - ColdFusion, English documentation - Adobe Learning Resources
Copy link to clipboard
Copied
I'm a longtime CF person and have no experience with CFChart. What I have tried is I have looped through my query and brute force added up the values for each field, then used those numbers to control the width of a colored GIF, which shows my data (but it doesn't look as nice as it could, and will become problematic should my database take on thousands of records.
The example I am trying to solve (as I wrote above) involves various fields in a database to which a user can answer "yes" (1) or "no" (0), and I would like to have a chart of how many people said "yes" for each field in my table. This seems like a specific graph, but also one that might come up fairly often (particularly on displaying results of surveys that have checkboxes).
I have not found any tutorials specific to this - so that's what I'm asking for. It almost seems like a generically common enough sort of charting task, that I would think there almost might be a built-in function.
Again - any help would be appreciated. As I find time, I will also try to read through all the documentation thoroughly - although I don't really need to use CFChart much in my daily life (this is sort of a one-time need).

