Jun 11, 2009

Charts with Power WebPart ( Management-Eye-Catchers )

In this post I’ll give you some ideas how you can script charts in SharePoint with Power WebPart featuring Microsoft Chart Controls.

Visualizing a SharePoint list as a pie

image

image

Setup and Configuration:

  1. 1. Download and install Microsoft Chart Controls (ensure that System.Web.DataVisualization.dll is either in the GAC or in the web app’s bin folder)
  2. 2. Download and install Power WebPart (follow the instructions in the readme.txt)
  3. 3. To use the Chart Controls in ASP.NET or SharePoint you have to modify the web.config:

Add this line to appSettings section:

<add key="ChartImageHandler" value="Storage=session;Timeout=20;" />

Add this line to the httpHandlers section:

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

The Script

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.DataVisualization")

$chart = New-Object System.Web.UI.DataVisualization.Charting.Chart
$series = new-object System.Web.UI.DataVisualization.Charting.Series
$chartArea = New-Object System.Web.UI.DataVisualization.Charting.ChartArea
$legend = New-Object System.Web.UI.DataVisualization.Charting.Legend

function createchildcontrols($controls)
{
$data = $web.Lists["Chart"].Items.GetDataTable()

$chart.DataSource = $data
$chart.Width=500

$series.ChartType = [System.Web.UI.DataVisualization.Charting.SeriesChartType]::Pie
$series.XValueMember ="Title"
$series.YValueMembers ="Value"
$series.ShadowOffset = 2
$series.IsValueShownAsLabel = $true

$chart.Series.Add($series)

$chartArea.Area3DStyle.Enable3D = $true
$chart.ChartAreas.Add($chartArea)

$chart.Legends.Add($legend)

$controls.Add($chart)

$chart.DataBind()

$series.Points.FindMaxByValue()["Exploded"] = $true
}

This just one example! The Chart Control is really mighty! Download the chart control examples from Microsoft to get an impression:


ChartImgCACU0PM6 ChartImgCAEO5EDD Bollinger2



The limitation is your imagination!

20 comments:

Share said...

Good information about SharePoint Charts

Anonymous said...

I love this, as I always found the built-in SharePoint chart functionality to be insufficient. It would be great if you could add an Excel-style GUI, so that non-developers could more easily use this.

Dave said...

Is there a missing step in the instructions or somethng missing? Tried this, but I get the error Error on render
Exception:
Object reference not set to an instance of an object.
Stack:
at iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at iLoveSharePoint.WebControls.PowerWebPart.Render(HtmlTextWriter writer)

Christian said...

Hi Dave,
I would say no. But I'll double check this on another system. Or do you have it running already? You couls also ensure that list title and the columns match to the names in the example.
Bye, Christian

Dave said...

Thanks for replying Christian,

I tried this on a second "clean" MOSS 2007 SP2 system, step-by-step, and still no go.
The list is called Chart, in the same site. It has Title and Value columns, with the same numbers as your screenshot. I tried different data types for Value (text, number) but still the same error. The chart controls are installed, as is .net3.5sp1.
The webconfig for webapp under this site has the two edits you mentioned, and iis was restarted. The script was copied from your "clipboard copy" on your website using your (cool) PowerGui integration, and saved into the Script window in your web part. The editor script is all commented out.
I don't have AJAX or JQuery installed or selected in the web part properties.
This is an awesome post, as are most of yours and I'd love to get this working if you see something I missed or have any ideas.
Thanks.

Christian said...

Hi Dave,

I just checked the configuration on a new Web Application and it works like a charm.
The "Object reference not set to an instance of an object" could indicate that the System.Web.DataVisualization.dll could not found. Please check that the Assembly is in Global Assembly Cache(GAC). You can also check this through executing this line in PowerShell directly "[System.Reflection.Assembly]::LoadWithPartialName("System.Web.DataVisualization")". If returns null the assembly could not be found. At the moment I haven't any other idea. Hope this helps.
Bye, Christian

Anonymous said...

Hi,
I seem to have the same problem as Dave has.
I tried the "[System.Reflection.Assembly]::LoadWithPartialName("System.Web.DataVisualization")".
and it finds the dll from GAC.

I am using a brand new installation of WSS 3.0 SP2.

Is there a way to print to your debug-screen so I could see what is inside variables ?

regards,

petri.

Christian said...

Hi Petri,

can't tell you what the cause could be. As you suggest you could use the debug console to find further informations.
1) Start the debug console (in the Tools Folder)
2) Set in the Web Part Editor the console to tour your IP (Port:8777)
2a) Click to ping debug console to verify tthat the connections works
3) check the debug flag
4) apply
5) to now you should be able to step through the lines

When you choose suspend (s). You can enter scripts in the debug console and use the variables. To exit enter exit.

Hope you will get it running.
Bye, Christian

electronic signature said...

This פרקדקמאשאןםמ will be helpful to everyone who will use it, including me. Keep doing what you are doing ! Thanks for sharing with us your web-site.

maymay said...

On the other hand, present day types of Breitling are actually hublot replica sale which has a branded point while using superimposition involving page N for the center plus the significant wings which in turn represent that every designer watches involving Breitling are generally capable throughout air flow, normal water along with in floor in the globe. Breitling Ref E56321 Breitling Urgent situation rolex replica uk Minimal Format Titanium is often a old-fashioned enjoy which in turn seems to be consequently wonderful which a gentleman will certainly experience sensible along with classy. Your orange deal with in the call is basically interesting. A new pre-owned Breitling enjoy is incredibly crucial tool to your man or woman. By way of never ending sequence, family members cartier replica employ these kind of amazing designer watches. Your impressive design and style along with eye-catching coloring using substantial rated operation include the hallmarks involving Breitling enjoy. Navitimer can be a real qualitative enjoy which in turn athletes, pilots along with stars love to don. Your specialised on this enjoy can be that will many experts have made from logarithmic excess skin. The idea operates as being a navigational instrument. Old-fashioned Breitling Datora Chronograph To locate cartier replica sale is usually an outstanding wristwatch. This specific amazing enjoy was made which has a spectacular chrome steel scenario. Your off white shaded call is usually an argument involving destination. You will find there's impressive oblong fashioned image for the rolex replica uk using a pair of dominant dark-colored shaded sub-dials. This specific enjoy can be set with guide book turning activity. It can be exceptional occasion keeper. Within this interconnection, one can possibly look for your amazon as well as Amazon.com to buy the used or vintage Breitling watches. The price of every model is reasonable.

Hug Day said...

hug day 2016 Images
happy hug day 2016 Date SMS Messages Quotes
Hug day Celebration Ideas For Him/Her
hug day sms for gf

风骚达哥 said...

20160423 junda
air jordans
cheap oakley sunglasses
kate spade outlet
adidas stan smith
ray ban sunglasses
michael kors outlet
nike air max shoes
cheap omega watches
yeezy boost 350
michael kors outlet online
michael kors outlet online
nike free runs
air jordan uk
michael kors outlet online
pandora charms
ray ban outlet
calvin klein outlet
fitflops sale clearance
toms outlet
nike huarache white
sac longchamp
toms outlet
michael kors outlet clearance
bottega veneta outlet
armani watches
gucci handbags
nike blazer
oakley sunglasses
true religion jeans
cheap jordans
ray bans
hollister
bottega veneta handbags
jimmy choo outlet
oakley sunglasses
converse
prada outlet
reebok shoes
true religion
burberry outlet

Libin Huang said...

20160426libinhollister clothing store
oakley sunglasses
michael kors handbags
tiffany outlet
ray-ban sunglasses
gucci outlet online
ray-ban sunglasses
burberry outlet online
coach outlet canada
ray-ban sunglasses
herve leger outlet
ray ban sunglasses sale
air max 90
oakley sunglasses
adidas wings shoes
michael kors outlet
michael kors factory outlet
louis vuitton bags
michael kors online outlet
nba jerseys
ralph lauren pas cher
oakley sunglasses
toms shoes
nike air max 90
nike tn pas cher
air max 90
lululemon outlet
nike air force 1
true religion outlet
michael kors outlet
burberry outlet store
ray ban sunglasses
kobe shoes
true religion outlet
discount michael kors handbags

Yuanyuan Lin said...

7.14lllllyuan"tiffany and co"
"michael kors outlet"
"hollister uk"
"michael kors outlet"
"salomon shoes sale"
"ralph lauren outlet"
"bottega veneta outlet online"
"fred perry polo"
"true religion jeans"
"michael kors outlet"
"camisetas futbol baratas"
"cartier outlet store"
"hollister"
"christian louboutin shoes"
"nike soccer shoes"
"polo ralph lauren"
"polo ralph lauren"
"michael kors outlet"
"longchamp handbags"
"fitflops sale"
"michael kors outlet"
"coach outlet online"
"louis vuitton handbags outlet"
"adidas shoes"
"tory burch shoes"
"chrome hearts eyewear"
"tory burch outlet"
"michael kors outlet"
"replica watches"
"burberry sunglasses on sale"
"louis vuitton bags"
"coach outlet"
"jordan shoes 2015"
"michael kors outlet"
"abercrombie outlet"
7.14

Fangyaya said...

michael kors purses
christian louboutin outlet
burberry handbags
coach outlet online
fitflop clearance
jordan 3s
michael kors
michael kors outlet
air jordan 8
replica rolex watches
adidas outlet store
michael kors outlet clearance
retro 11
cheap true religion jeans
cheap true religion
nike air max uk
replica rolex watches
christian louboutin shoes
supra footwear
louis vuitton bags
designer handbags
polo ralph lauren
cheap basketball shoes
adidas originals
coach outlet store online
coach outlet
cheap jordan shoes
oakley vault
jordan retro 4
coach factory outlet online
louis vuitton outlet
air jordan shoes
ed hardy outlet
gucci handbags
adidas yeezy
kobe shoes
discount jordans
cheap jordans
oakley sunglasses
coach factory outlet online
20168.8chenjinyan

Justin said...

Stafford Loans have the in addition to point that it doesn't require the standard of credit check not the slightest bit at all to wind up qualified to profit of understudy advances. Notwithstanding, credit check may turn into an issue on account of non-need-based advances, for example, Grad Plus Loans and Parent Loans. Cash Advance

dada24 Xu said...

cheap oakleys
ralph lauren pas cher
canada goose
michael kors outlet clearance
true religion outlet
armani exchange
gucci outlet
ed hardy
ugg boots
ray ban sunglasses
2016921caiyan

dada24 Xu said...

cheap oakleys
ralph lauren pas cher
canada goose
michael kors outlet clearance
true religion outlet
armani exchange
gucci outlet
ed hardy
ugg boots
ray ban sunglasses
2016921caiyan

Paulo said...

This agent is basically a $75 billion asset which falls under the Homeowner Stability Initiative. Its fruitful execution will bring about bank advance adjustments that will start to back off the rate of abandonment the country over. cash advance

raybanoutlet001 said...

oakley sunglasses
pandora outlet
jordan shoes
ecco outlet
coach outlet
ugg boots
gucci shoes
coach outlet online
christian louboutin shoes
ugg boots