Chart Web Part – SharePoint 2013

In SharePoint 2010, there was a Chart Web Part that you could connect to another web part on the same page, to a list anywhere in the site collection, to an external content type, or to data from an Excel workbook.

In SharePoint 2013, this does not exist OOB.

However, if you copy and paste this code and save it as an XML file, you can upload it and use it in 2013!


<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.Office.Server.WebControls.ChartWebPart,microsoft.office.server.chart,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import Chart Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Chart Web Part</property>
<property name="Description" type="string">Helps you to visualize your data on SharePoint sites and portals.</property>
</properties>
</data>
</webPart>
</webParts>

Navigate to the page you where you want to add a chart and go into edit mode.

Click the insert tab and select Web Part.

Click “Upload a Web Part” and browse to the XML file you saved from the code above.

Click Upload.

chart

The page will refresh so you’ll have to go back into the Web Part menu to select the Chart Web Part from the Imported Web Parts category.

chartwebpart.PNG

Click Add and voila!

chartwebpart1.PNG

Save the page before you click on the Data & Appearance or Advance Properties links.

Update List/Library Columns With External Content Type Columns

Scenario:

You have a column on a custom list or library that needs to be back-filled with data from an External Content Type (ECT).

Solution:

Create a list from the ECT and use PowerShell to update your custom list’s column with the ECT’s list column.

Creating a list (assuming you already connected an ECT):

Open SharePoint Designer 2013 and navigate to your External Content Types. Click on the ECT you need data from and click “Create List & Form”.

Name the list whatever you want and click OK.

The list will be created in the site or subsite you’re connected to in SharePoint Designer.

Updating Custom List With ECT List Column:

My example shows how to match Customer names in an ECT with corresponding Folders in a document library to update the Status column.  If you need to update every item in a list, comment out line 78, un-comment lines 72 and 81, then remove the query.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the context - top level site collection
$ctx = Get-SPServiceContext http://sp2013

#Get the scope
$scope = new-object Microsoft.SharePoint.SPServiceContextScope $ctx

#Get the target site collection
$webTarget = Get-SPWeb -identity "http://sp2013/sites/customer"

#Get the ECT List
$list = $webTarget.Lists["Entity List"]

#Array to Hold Result - PSObjects
$ListItemCollection = @()

#Get All List items. Replace -name "Name" with the column name on the ECT list.
#Add more columns if required
$list.Items | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Entity" -value $_["Entity"]
$ExportItem | Add-Member -MemberType NoteProperty -name "Status" -value $_["Status"]

#Add the object with property to an Array
$ListItemCollection += $ExportItem
}

#Export the result Array to CSV file
$ListItemCollection | Export-CSV "E:\SharePoint\EntityStatus.csv" -NoTypeInformation

#Dispose the web Object
$webTarget.Dispose()

#Pause for 10 seconds for the CSV file to populate all the way.
Start-Sleep 10

function Update-SPList()
{
#Import to destination list
#This section of the PowerShell will loop through the csv file we created and update the Status column in our Customer Folders library.
$csvVariable= Import-CSV -path "E:\SharePoint\EntityStatus.csv"

# Destination site collection. You can use any site, it does not have to be in the same collection as ECT list.
$WebURL = "http://sp2013/sites/customer"

# Destination list name
$listName = "Customer Folders"

#Get the SPWeb object and save it to a variable
$webDestination = Get-SPWeb -identity $WebURL

#Query ONLY folders.
$query = New-Object Microsoft.SharePoint.SPQuery;
$query.Query =
" <Where>

<Eq>
<FieldRef Name='FSObjType' />
<Value Type='Integer'>1</Value>
</Eq>

</Where>";

$list = $webDestination.Lists[$listName]

#If you want to update all items, remove the query and uncomment the following line
#$items = $list.Items

#loop through csv file
foreach($row in $csvVariable)
{
#Updating queried items
$updateitem = $list.GetItems($query) | Where {$_["Title"] -eq $row.Entity}

#Updating all items
#$updateitem = $items | Where {$_["Title"] -eq $row.Entity}

#loop through SharePoint list
Write-Host $row.Entity

$updateitem["Status"] = $row.Status
$updateitem.Update()
}

if ($webDestination)
{
$webDestination.Dispose()
}
}
Update-SPList