Friday, September 19, 2008

Procedure to create BI Chart in WSS

· Install SMARTPART tool in SharePoint
· To activate SMARTPART select Site Settings àSite Collection Features à Activate
· Create list in your WSS site
· Create a new web application in visual studio
· Right Click on Tool BoxàChoose Items-> Browseàadd the webchart.dll. Now you will see the Chart Control in the tool box
· Insert a web user control in the design window then insert a Chart control inside the web user control.
· Add the following reference in your web application Windows SharePoint Services under .NET Tab ‘Share Point Services’
· Add the following namespaces in your code System.Drawing, WebChart,WebChart.Design.
· Add the following code in code window of the usercontrol.aspx.cs file


protected void Page_Load(object sender, EventArgs e)
{
ColumnChart chart = new ColumnChart();
chart.Fill.Color = Color.FromArgb(50, Color.SteelBlue);
chart.Line.Color = Color.SteelBlue;
chart.Line.Width = 2;
chart.Legend = "HCL Year by Year Growth information Chart";
chart.Data.Add(new ChartPoint("1997", 69));
chart.Data.Add(new ChartPoint("1998", 80));
chart.Data.Add(new ChartPoint("1999", 65));
chart.Data.Add(new ChartPoint("2000", 18));
chart.Data.Add(new ChartPoint("2001", 70));
chart.Data.Add(new ChartPoint("2002", 83));
chart.Data.Add(new ChartPoint("2003", 65));
chart.Data.Add(new ChartPoint("2004", 98));
chart.Data.Add(new ChartPoint("2005", 92));
chart.Data.Add(new ChartPoint("2006", 78));
chart.Data.Add(new ChartPoint("2007", 90));
ConfigureColors();
ChartControl1.Charts.Add(chart);
ChartControl1.RedrawChart();
}
private void ConfigureColors()
{
ChartControl1.Background.Color = Color.FromArgb(75, Color.SteelBlue);
ChartControl1.Background.Type = InteriorType.LinearGradient;
ChartControl1.Background.ForeColor = Color.SteelBlue;
ChartControl1.Background.EndPoint = new Point(500, 550);
ChartControl1.Legend.Position = LegendPosition.Bottom;
ChartControl1.Legend.Width = 40;
ChartControl1.YAxisFont.ForeColor = Color.SteelBlue;
ChartControl1.XAxisFont.ForeColor = Color.SteelBlue;
ChartControl1.ChartTitle.Text = "HCL Year by Year Growth information Chart";
ChartControl1.ChartTitle.ForeColor = Color.White;
ChartControl1.Border.Color = Color.SteelBlue;
ChartControl1.BorderStyle = BorderStyle.Ridge;
}

· Add the following code inside the assemblies tag in webconfig(C:\Inetpub\wwwroot\wss\VirtualDirectories\65455) file

[add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/]
[add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/]
[add assembly="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/]

· Copy WebChart.dll.refresh and WebChart.dll from Website’s Bin folder and paste these two file in our website’s _app_bin folder
· Copy WebCharts folder from our website and paste it in C:\Inetpub\wwwroot\wss\VirtualDirectories\65455
· Create one folder in our port number with the following name “UserControls” then paste the two files that is UserControl.aspx and UserControl.aspx.cs
· Then select Site Settings à Edit Page à Click Add Web Part à Check the Smart Part Click Ok.
· Click Edit à Modify Shared Web Part
· Select the user control from the list from the tab “User control to display” then click Apply and click ok.
· Now you can see the Chart in your website

1 comment:

shanky said...

This will be very usefull for me sir.
thanks