03-29-2010 06:54 PM
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!
04-05-2010 02:08 PM
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.