Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to everybody,

first let me describe what i want to do:

I want to display the frequency of the entries in a mysql datatable to a chart
(bar graph).

For example the table contains the entries: 5 times entry1, 8 times entry2 and 15 times entrie3. I want to display that to a chart(bar graph). I think you can image how it would look like. The X-Axis contains the names of each entry and the height of the bar represents the frequency of that entry. I need to sort the bars by frequency (most recorded entry first)

Can somebody tell me if there is an easy way to do this? I dont know if the best way is to count the entries and extract the count number to an integer. Anyway i have no clue how to do this. Maybe there is a direct way to connect a chart to a mysql database and display the data in the desired way?

I would appreciate it if somebody would give ma a suggestion, Thanks a lot.

What I have tried:

sql statements: Count, Groupe by, DESC
Reading about Charts in C#
Posted
Updated 17-Nov-16 2:27am

1 solution

Try:
SQL
SELECT Frequency, COUNT(*) FROM MyTable GROUP BY Frequency
Load that into a DataTable via an SqlDataAdapter, and pass that to your chart, or convert it to a collection of objects which contains the X and Y data.
This may help: Using a Chart With Multiple Lines From A Collection[^]
 
Share this answer
 
Comments
Member 12341536 17-Nov-16 9:29am    
Hi thank you for answering,

well these are a lot of steps obviously. Would you give me an example code on how to pass information to the chart? this is my biggest problem.. :(
Member 12341536 17-Nov-16 14:09pm    
I have figuered it out myself, thanks anyway for the suggestion.
OriginalGriff 17-Nov-16 14:19pm    
Well done! You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900