Friday, 3 June 2011

SharePoint 2007- ASP:Chart

In a recent project one of the requirements was to produce a chart from 
data held within a SharePoint list.  
To fulfil this requirement I used the asp:Chart control.  The following steps outline how to set this up:

@ Register Assembly="System.Web.DataVisualization,

                      Version=, Culture=neutral,



             TagPrefix="asp" %>


  1. <asp:Chart ID="Chart1" runat="server" />

Web Config:
Add the following tag within the <pages><controls>

add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Add the following tag within <httpHandlers>

<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />

Useful Methods

Set Point:
private void SetPoint(string Series, int pointX, int pointY)
Chart1.Series[Series].Points.AddXY(pointX, pointY);

Set Legend:

private void SetLegend(string Series, string LegendText) 
Chart1.Series[Series].LegendText = LegendText;

No comments:

Post a Comment