altho there is xslt, unfortunatly its not the way thats right for me.
The list is pulled dynamically and it will display multiple graphs on the same page for any survey on any site (surveys collected and shown on one page).
I managed to figure it out yay:
to achive the given result I did:
1) get list
2) create chart
3) get fields name and value from list (make sure its a choice value)
4) loop through each question
5) for each question loop through each possible answer
6) use spquery to get the total using the question and possible answer
7) populate the result on the chart
8) once finished add chart to panel
9) add panel to controls
private void getSurveyGraphResultForAll(string _ListName, string _SiteName, string _ViewName, Panel BODY)
{
using (SPSite site = new SPSite(_SiteName))
{
using (SPWeb web = site.OpenWeb())
{
try
{
if (!string.IsNullOrEmpty(_ListName))
{
SPList list = null;
try
{
list = web.Lists[_ListName];
SPUser currentUser = SPContext.Current.Web.CurrentUser;
SPListItemCollection items = list.GetItems();
Random rnd = new Random();
Chart1.Width = 412;
Chart1.Height = 296;
Chart1.ImageStorageMode = ImageStorageMode.UseImageLocation;
Chart1.ID = rnd.Next().ToString();
Chart1.RenderType = RenderType.ImageTag;
string imagespath = "/chartimages/";
Chart1.ImageLocation = imagespath + "ChartPic_#SEQ(200,30)";
Chart1.Palette = ChartColorPalette.BrightPastel;
Title t = new Title(list.Title, Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
Chart1.Titles.Add(t);
Chart1.ChartAreas.Add("Series 1");
foreach (SPListItem item in list.Items)
{
foreach (SPField field in item.Fields)
{
if (field.TypeAsString == "Choice")
{
if (Chart1.Series.FindByName(field.Title) == null)
{
Chart1.Series.Add(field.Title);
}
SPFieldChoice fd = (SPFieldChoice)field;
foreach (string str in fd.Choices)
{
SPQuery responseQuery = new SPQuery();
responseQuery.Query = @"<Where><Eq><FieldRef Name=" + field.InternalName.ToString() + " /><Value Type=\"Choice\">" + str + @"</Value></Eq></Where>";
Chart1.Series[field.Title.ToString()].Points.AddY(list.GetItems(responseQuery).Count);
}
}
}
}
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart1.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderWidth = 2;
Chart1.Legends.Add("Legend1");
Chart1.Legends["Legend1"].Enabled = true;
BODY.Controls.Add(Chart1);
}
catch (Exception a)
{
//catch exception
}
}
}
catch (Exception ax)
{
//catch exception
}
}
}
}
hope this is usefull to someone out there as I couldnt find anything about this online and this is what iv come up with so far.