Using the MSChart Controls in SharePoint / MOSS 2007


The project I’m working on right now involves prototyping data mining and analysis tools and integrating them into the SharePoint / MOSS environment. These applications have code behind of course and relatively complex visual features involving AJAX, AJAX Control Toolkit, Javascript, jQuery and the MSChart controls.

Getting the chart controls to work in SharePoint is no different to getting them to work in ASP.NET, well almost, with SharePoint you have to make a couple of extra changes.

First, ensure that you’ve installed the MSChart controls on each of your WFE servers and verify that the chart assembly is in the GAC by entering this command at a prompt;

gacutil /l|find "system.web.datavisualization" /i

And you should see something like;

System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Web.DataVisualization.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL

Next come the web.config changes

Enter this fragment in the <SafeControls> section

<SafeControl Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TypeName="*" Safe="True" AllowRemoteDesigner="True" />

Enter this fragment in the <system.web>/<httpHandlers> section

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

Note: Most of the documentation/blogs ommit the POST verb, which causes an error if the Chart control is created as a result of a PostBack (i.e. a POST)

While not strictly neccesary, enter this fragment in the <system.web>/<compilation>/<assemblies> section

<add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Enter this fragment in the <system.webServer>/<httpHandlers> section

<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Note: Most of the documentation/blogs ommit the POST verb, which causes an error if the Chart control is created as a result of a PostBack (i.e. a POST)

Enter this fragment in the <configuration>/<appSettings> section

<add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=/_layouts/Images/MSChartImages/;" />

Note: You must give write/create permissions to the Application Pools Identity for the Web Application, on the URL given above in the value parameter.

With all this done, restart IIS and happy charting.

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

4 thoughts on “Using the MSChart Controls in SharePoint / MOSS 2007

  1. Hello,

    I’ve implemented a dynamic WebPart that builds Charts from a DataSet… it’s working perfectly but now i’m facing a problem…

    I’ve deployed the solution on a sharepoint server and the problem is… Only farm administrators are able to see the Charts ! the code runs to the last line… no errors no exceptions it binds the Chart on C# but IE throws “Unauthorized access” wanted that this WebSite to be visible by anonymous but even a Site Admin can’t see the Render !

    This has something to do with the Chart ddl access ? it has to… i don’t know how to solve this 😦

  2. VRC, check the MSChart configuration in appSettings in your web.config () it may be that appropriate filesystem permissions are not in place on the Url path, alternatively set the Storage parameter to memory, if your WFE’s have enough RAM capacity

  3. did anyone face this issue after doing the above configurations.

    Invalid temp directory in chart handler configuration [C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\template\images\MSChartImages\].

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s