Walkthrough: Creating a Chart Control with Data from an Analysis Services Cube
Applies To: Microsoft Dynamics AX 2012 R2
A Chart Control is a User Control option to display chart data in Enterprise Portal. A Chart Control can display data from a Report Data Provider (RDP) class or from an analysis cube. This walkthrough demonstrates how to use the features in Microsoft Dynamics AX to create and deploy a Chart Control for Enterprise Portal that displays analysis cube data. For information about Chart Controls that display RDP data, see How to: Create a Chart with Data from a Report Data Provider Class. The walkthrough illustrates the following tasks:
Creating an EP Web Application project.
Creating a Chart Control.
Deploying the Chart Control.
Viewing the Chart Control in Enterprise Portal.
Prerequisites
To complete this walkthrough, you will need:
Microsoft Dynamics AX
The default Analysis Services project, deployed and processed. For more information, see Configure Analysis Services.
Visual Studio 2010
Enterprise Portal with Administrator status. For more information, see Configure Analysis Services.
Creating the EP Web Application Project
Use Visual Studio to create User Controls for Enterprise Portal.
To create the EP Web Application project
Start Visual Studio. If User Account Control (UAC) is active, make sure that you start Visual Studio with administrative privileges. To do this, right-click the shortcut for Visual Studio and then click Run as administrator.
In the File menu, click New, and then click Project.
In the New Project window, select .NET Framework 3.5 as the framework version to use.
Important
For this release of Microsoft Dynamics AX, the EP Web Application project must target the .NET Framework 3.5 to work correctly.
In the Installed Templates list, select Microsoft Dynamics AX. If you do not see this project template, make sure that you have Visual Studio Tools for Microsoft Dynamics AX installed. For more information, see How to: Set Up Visual Studio for Enterprise Portal Development.
Choose the EP Web Application template.
Specify a name for the project, and the location of the folder where you want to store the files for the project.
Click OK to create the project.
Creating a Chart Control
Create a Chart Control that displays general ledger profit by date.
To create a Chart Control
In Visual Studio, use Solution Explorer to select the project you created.
In the Project menu, click Add New Item.
In the Add New Item window, expand the Visual C# group of installed templates.
Click Microsoft Dynamics AX, and then click the EP Chart Control template.
For the Chart Control name, type AxProfit.ascx.
The name entered identifies the chart in SharePoint.
Click Add. The new Chart Control is added to the project.
In Solution Explorer, right-click AxProfit.ascx and then click View Designer.
The following components are included in the layout for the general ledger profit chart:
AxChartDataSource - AxProfitDataSource
Chart - AxProfitChart
The DataSourceID property of the chart has been set to AxProfitDataSource.
AxChartBehavior - AxProfitBehavior
Right-click the AxChartDataSource – AxProfitDataSource component in the layout, and then click Properties.
Verify that the DataType property is set to MDXQuery, to indicate that the data is coming from an Analysis Services cube.
In the CommandText property, click the ellipsis button (...) to open the OLAP query builder where you can enter a Multidimensional Expression (MDX) query string to access analysis cube data. For information on MDX syntax, see MDX Query Fundamentals.
In this example, you will enter an MDX query that returns profit for the years 2008, 2009, and 2010. Change the query as needed based on your data. Enter the following MDX query:
SELECT {[Measures].[General ledger gross profit - accounting currency]} ON COLUMNS,{[Transaction date].[Year].&[2008-01-01T00:00:00],[Transaction date].[Year].&[2009-01-01T00:00:00],[Transaction date].[Year].&[2010-01-01T00:00:00]} ON ROWSFROM "General ledger cube"
Click the execute query ! button. The results of the MDX query are displayed.
Note
The column headers of the results provide the XValueMember value and YValueMembers value to update the Series property in the next step.
Click OK to save the query text.
In the Design, right-click the AxProfitChart component in the layout, and then click Properties.
In the Series property, click the ellipsis (…) button to open the Series Collection Editor.
In the Series Collection Editor, set the following properties:
Property
Value
XValueMember
[Transaction date].[Year].[Year].[MEMBER_CAPTION]
YValueMembers
[Measures].[General ledger gross profit - accounting currency]
Click OK to save the Series value members.
Use the Properties window to change the look and feel of the chart. For example, you can add text to the Titles property that will display as a title on the chart.
In Solution Explorer, right-click the chart project, and then click Add [ProjectName] to AOT.
In the File menu, click Save All.
Deploying the Chart Control
After you have created and saved the Chart Control, you can display it in Enterprise Portal to verify its functionality. In this walkthrough, you will use the Deploy to EP functionality in the AOT to add the chart to Enterprise Portal. For information about how to display a chart in an existing page, see How to: Add Web Parts to add a User Control Web Part.
To deploy the Chart Control
Open the Microsoft Dynamics AX client with administrative privileges. To do this, you must right-click on the icon for Microsoft Dynamics AX and then click Run as administrator.
Open the Development Workspace.
Display the AOT.
In the AOT, expand the Web > Web Content > Managed node. This node contains all of the User Controls that have been defined for Enterprise Portal.
In the list of managed components, locate the AxProfit node. This is the managed content node for the Chart Control that you just created.
Right-click the AxProfit node, and then click Deploy to EP.
The Deploy to EP dialog box is displayed. Set the Web module lookup to Home\Sales to indicate that the new resources will be used in the Sales site for Enterprise Portal. Click OK.
Microsoft Dynamics AX creates a SharePoint page named AxProfit that is located in the Sales site. This page contains the general ledger profit chart that you created. Microsoft Dynamics AX also creates a web menu item named AxProfit that points to the new page. Click Close to close the Infolog.
Viewing the Chart Control in Enterprise Portal
After you have created the page that contains the Chart Control, you can view the page in Enterprise Portal.
To view the Chart Control in Enterprise Portal
Using a web browser, open Enterprise Portal. The typical URL to access Enterprise Portal is:
https://<server>/sites/DynamicsAx/
Substitute the name of the server on which Enterprise Portal is installed.
Click Sales on the top link bar to display the Sales module site. This is the site that you deployed the new page to.
In the Site Actions menu, click View All Site Content.
In the Document Libraries section, click Enterprise Portal. This is the document library that pages for the Sales site are stored in.
Locate the AxProfit page in the list of pages for the Sales site.
Click the link for the AxProfit page to display it in Enterprise Portal. After a few moments, you should see a page that contains the Chart Control you created, displaying general ledger profit in the current company.
Next Steps
Recall that a web menu item was created when you deployed the Chart Control. You could add this web menu item to the navigation for Enterprise Portal, and then access the new page through standard Enterprise Portal navigation. See Page-level Navigation Overview or Walkthrough: Adding a Page to Navigation for more information about how to add the web menu item to the navigation. Another option is to add the User Control web part to an existing page, like a Role Center page. For information about how to display a chart in an existing page, see How to: Add Web Parts.