More Soma Please…

Developers are in a race with the Universe to create better idiot-proof programs, while the Universe is trying to create better idiots. So far the Universe is winning.

Using the MSChart Controls in SharePoint / MOSS 2007

Posted by Phil Harding on July 8, 2009

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.

One Response to “Using the MSChart Controls in SharePoint / MOSS 2007”

  1. [...] WebPart Lifecycle EventsORA-12705 Cannot access NLS data files or invalid environment specifiedUsing the MSChart Controls in SharePoint / MOSS 2007SqlDataReader, DataTable and Multiple ResultsetsConfigure Sharepoint (MOSS) Single Sign-OnDeleting [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>