Monday, June 20, 2011

Nexus between State Service and Chart Web Part in SharePoint 2010

While trying to display a simple bar chart in SharePoint 2010 from data contained in a Sales list, I ended up with the following error "The chart cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator."

If you are new to charts in SharePoint 2010 then no need to concern, as much of the overhead of is taken care of by SharePoint itself. For the developer its all about adding a "Chart Web Part" to  a page and assigning properties like linking to data source, selecting the chart of your choice and setting the appropriate titles and legends, that's it. Once you are done with all those properties, you will see the chart beautifully rendered on your page. The only drawback I came to find with inbuilt charts are that  they aren't that interactive when compared with a Silverlight charts, where with the later one could rotate, drill down, click certain portions to view more details and moreover a some rich 3D rendering like that. The built-in SharePoint Chart fits the bill for most usual business requirements.

Searching for the Service:
So coming back to the error which I was talking about. From the error message what I could infer was that "SharePoint State Service" wasn't available or running. I started to lookup for this service under Windows Services (services.msc) but didn't find any. Next I moved on to "SharePoint Central Admin"  where I navigated to "Application Management -> Manage Service Applications" there too the service wasn't listed. So seems like the service wasn't installed during farm configuration phase. 

Solution:
Now we are going to install the "State Service" (which itself is a Service Application in SP2010). 
  1. For this navigate to "SharePoint Central Admin -> Configuration Wizards -> Launch the Farm Configuration Wizard -> Click 'Start the Wizard' ". In next screen uncheck all the services except "State Service" (Note: Before unchecking other services, make sure you are not using any of those services in your project(s). Leaving every services checked, will make your SharePoint server crawl, running all of these services in a single server will consume more CPU cycles and memory. Normally in a production environment, each of these services will be running in different servers so as to offload the overhead from the WFE(Web Front End) SharePoint server.)
  2. Click OK and browse back to Central Admin (no need to continue with a new site creation).
  3. In the Central Admin page select "System Settings -> Manage Services on this Server" and search for the Service Application with named "State Service" and click the "Next" button , after which the status should be shown as "Started".
This error will show up not only for charts, but also when  trying to publish a page in SharePoint 2010. So going back to the page where I had placed the Chart Web Part. Hurray the chart was rendered as expected without any errors.  

No comments: