Creating more complex charts in the Cireson Portal
Here is an example of how that can be done in the Cireson Portal.
First, you need to define a data source. This query will give the number of open incidents, service requests and change requests which have not been resolved, completed or closed on each day.
;WITH lastTenDays AS <br>( SELECT TOP(10) CAST(DATEADD(dd,CAST(-(ROW_NUMBER() OVER (ORDER BY [object_id])-1) as INT),GETDATE()) as DATE) AS daydate<br> FROM sys.all_objects ),<br> WorkItemRange AS (SELECT wi.ClassId<br> , t.daydate<br> FROM lastTenDays t<br> LEFT OUTER JOIN WorkItem wi<br> ON CAST(wi.Created as Date) <= t.daydate<br> AND COALESCE(CAST(wi.ResolvedDate as Date),CAST(wi.ClosedDate as Date),CAST(wi.CompletedDate as Date),GETDATE()) > t.daydate <br> WHERE wi.ClassId in ('A604B942-4C7B-2FB2-28DC-61DC6F465C68','04B69835-6343-4DE2-4B19-6BE08C612989','E6C9CF6E-D7FE-1B5D-216C-C3F5D2C7670C'))<br>SELECT FORMAT(wir.daydate,'yyyy-MM-dd') [Date]<br> , SUM(CASE WHEN ClassId = 'A604B942-4C7B-2FB2-28DC-61DC6F465C68' THEN 1 ELSE 0 END) [Incident] <br> , SUM(CASE WHEN ClassId = '04B69835-6343-4DE2-4B19-6BE08C612989' THEN 1 ELSE 0 END) [ServiceRequest] <br> , SUM(CASE WHEN ClassId = 'E6C9CF6E-D7FE-1B5D-216C-C3F5D2C7670C' THEN 1 ELSE 0 END) [ChangeRequest] <br>FROM WorkItemRange wir<br>GROUP BY wir.daydate<br>ORDER BY 1<br>
Open the Portal as an administrator, and click on the Admin Settings link on the drop-down menu in the top right-hand corner. Click on the link for Dashboard Query Settings.
Click Add.
Enter 'Work Item Backlog' for the name
Set the Data Source as ServiceManagement
Copy/paste the SQL query from above.
Save the query.
Now open SQL Server and run this query against the ServiceManagement database.
select Id, Title<br>from DataSource<br>where Title = 'Work Item Backlog'
Copy the guid from the Id field returned by this query.
Now open the file explorer on the Portal server.
Browse to C:\inetpub\CiresonPortal\CustomSpace\views
Create a file called backlog.js in this folder.
Add this code to the file:
{<br> "Id": "backlog",<br> "layoutType": "semantic",<br> "pageTitle": "Backlog",<br> "view": {<br> "cssClass": "container-fluid",<br> "content": [<br> {<br> "cssClass": "row",<br> "content": [<br> {<br> "cssClass": "col-sm-12",<br> "content": {<br> "cssClass": "row",<br> "content": [<br> {<br> "cssClass": "col-md-12",<br> "type": "viewPanel",<br> "ViewPanelId": "vp-backlog"<br> }<br> ]<br> }<br> }<br> ]<br> }<br> ]<br> }<br>}
Next, open the subfolder called viewpanels in the views folder.
Create a file called vp-backlog.js in this folder.
Add this code to that file:
{<br> "Id": "vp-backlog",<br> "TypeId":"chart",<br> "Definition":<br> {<br> "content":<br> {<br> "title":"Backlog",<br> "queryId":"298E8367-8E90-DC38-7DD6-BBB0A164DA49",<br> "series":[<br> {"field": "Incident", "name": "Incident", "type": "line", "stack": false},<br> {"field": "ServiceRequest", "name": "ServiceRequest", "type": "line", "stack": false},<br> {"field": "ChangeRequest", "name": "ChangeRequest", "type": "line", "stack": false}<br> ],<br> "categoryAxis":{"field":"Date"},<br> "seriesColors":["orange", "blue", "green"]<br> }<br> }<br>}
Finally go back to the Portal and open the Navigation Settings menu from the drop-down menu in the top right-hand corner.
Add a new link to /view/backlog
Set the Title, behaviour, icon and visibility.
When you click on the link you should see:
You can specify a different chart type in the view panel. For example, this is the same data displayed as a stacking area chart.
Comments
I also found a simple solution displaying the backlog by date, but for one workitem type at the time. While mine only uses the standard capabilities in the portal, your end result is nicer This is what I had come up with:
SQL Table Widget
SQL Graph Widget - Query Name: Service Request Backlog Trend, Chart Type: Area, Category Field: Date, Value Field: Backlog
What would be needed to achieve the same result as yours is to be able to have multiple value fields columns for a line, bar or area graph and I think a check-box dropdown for the value field would be ideal
Thanks again,
Stephane
Hi @John,
Could you possibly repost the code from the original post? I'm working on trying to set something like your stacked line chart up and it would be incredibly helpful.
Thanks!
James