Επεξεργασία

Κοινή χρήση μέσω


Create a visualization (chart)

To create a visualization programmatically, you must create a record for the SavedQueryVisualization Entity or UserQueryVisualization Entity entity to create an organization-owned or user-owned chart respectively. This topic shows how to create a chart visualization and a web resource visualization.

Before you create a visualization

Before creating a visualization, make sure that you are aware of the following:

  • Type of visualization: If you want your visualizations to be available across the organization and don’t want to manage the access levels at a more detailed level, you might want to create an organization-owned visualization. However, if you’re concerned about the access privileges and security of your visualization, consider creating a user-owned visualization where you have more control over who can access it.

    Note

    Organization-owned visualizations can only be created by those users who have the System Administrator or System Customizer role.

  • Associated Entity: Visualizations are attached to entities. More information: Entities Supported for Visualizations. You can attach a chart to a supported entity by using the SavedQueryVisualization.PrimaryEntityTypeCode or UserQueryVisualization.PrimaryEntityTypeCode attribute.

Create a chart visualization

Charts require you to specify the underlying data for the charts and how the charts will look in the form of data description and presentation description XML strings. More information: Specifying Chart Data and Sample Charts.

For a complete sample on how to create an organization-owned chart, see Sample: Create, Retrieve, Update, and Delete (CRUD) a Chart.

Create a multi-series chart

Multi-series charts map multiple series (vertical) axis values to a single category (horizontal) axis value. The only difference from a single series chart is that these charts have multiple <measurecollection> and corresponding <series> elements specified in the XML strings. Each <measurecollection> element contains a child element called <measure> that defines a series (vertical) axis value for the same category (horizontal) value. More information: Understanding Charts: Underlying Data and Chart Representation.

For a sample multi-series chart and the corresponding data description and presentation descriptions XML strings, see Multi-Series Chart.

Create a web resource visualization

Visualizations containing web resources don’t require you to specify the data description and presentation description XML strings. The following sample demonstrates how to create an organization-owned visualization containing a web resource by using the SDK.

SavedQueryVisualization newWebResourceVisualization = new SavedQueryVisualization()  
{  
   Name = "Sample Dashboard Visualization",  
   Description = "Sample organization-owned visualization",  
                           PrimaryEntityTypeCode = Account.EntityLogicalName,  
   WebResourceId = new EntityReference(WebResource.EntityLogicalName, _webResourceId))  
  
};  
_orgOwnedVisualizationId = _serviceProxy.Create(newWebResourceVisualization);  
  

If you want to create a web resource visualization by using the Dynamics 365 for Customer Engagement web application, you must create an XML file in the following format, and then use Import Chart in the ribbon to import the visualization.

<visualization>  
  <name>Visualization_Name</name>  
  <description>Description</description>  
  <webresourcename>Name_Of_An_Existing_Web_Resource</webresourcename>  
  <primaryentitytypecode>Entity_Logical_Name</primaryentitytypecode>  
  <isdefault>Value: true or false</isdefault>  
</visualization>  

For example, to create a Sample Visualization that displays an existing Web resource called new_TestWebResource, and the visualization should be attached to the account entity, the XML should look like.

<visualization>  
  <name>Sample Visualization</name>  
  <description>Sample Web Resource Visualization.</description>  
  <webresourcename>new_TestWebResource</webresourcename>  
  <primaryentitytypecode>account</primaryentitytypecode>  
  <isdefault>false</isdefault>  
</visualization>  

See also

Charts
Specifying Chart Data
Actions on Chart
Sample Charts
Data Visualization and Analytics
Sample: Create, Retrieve, Update, and Delete (CRUD) a Chart