Community
Showing results for 
Search instead for 
Do you mean 
Reply

SQL Chart Control - secrets to creating pie charts, bar charts, etc.

New Member
Posts: 1
Country: United States

SQL Chart Control - secrets to creating pie charts, bar charts, etc.

Hello,

 

I've successfully been creating list views using the SQL Chart control but I'm having difficulties creating graphical elements. Can you tell me the proper order and/or requirements to make a pie or bar chart? I.E, do I have to list the fields in a particular order? Does there have to be a Group By clause?

 

Any hints/help you can provide will be greatly appreciated!

 

 

Nickel Elite Contributor
Posts: 937
Country: USA

Re: SQL Chart Control - secrets to creating pie charts, bar charts, etc.

It depends on the target graph element as to the order and datatype of the SQL return.

 

For example if you are looking for a bar chart then you must return the value then the label for each entry you want on the bar chart.  The control expects only 2 columns and n number of rows (it graphs a new bar for each row).  Most of the other graphs follw this same pattern but I haven't used all of them so I don't want to claim it's the same for each.

 

The chart is smart enough to know that if you have 6 rows it needs 6 bars and will label and graph correctly, but it assumes the value is a number type, it won't render the graph if that first column is text.  That means if you are using some sort of aggregate function to supply the value, then you'll need a group by in your SQL statement, (group by your label field). 

 

The best way to get some idea of what to return is to take the datachart.xml from existing (or previous control) that already uses chart controls by default and look at that SQL for a better idea of how to structure your data return for a graph.