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


Understand charts: Underlying data and chart representation

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Charts display data visually by mapping textual values on two axes: horizontal (x) and vertical (y). In Microsoft Dynamics 365, the x axis is called the category axis and the y axis is called the series axis. The category axis can display numeric as well as non-numeric values whereas the series axis only displays numeric values.

Charts in Microsoft Dynamics 365 can be further classified into the following:

  • Single-series charts: Charts that display data with a series (y) value mapped to a category (x) value.

  • Multi-series charts: Charts that display data with multiple series values mapped to a single category value. Multi-series charts include stacked column charts, which vertically display the contribution of each series to a total across categories, and 100% stacked column charts, which compare the percentage that each series contributes to a total across categories. You can combine different compatible chart types in multi-series charts, for example, column and line, bar and line, and so on.

Note

Multi-category charts can be created through the web application or by modifying the XML strings described here.

While authoring a chart in Microsoft Dynamics 365 using the SDK, you need to consider the following two important aspects:

  • Underlying data for the chart: Specified using the data description XML string.

  • Data representation (appearance): Specified using the presentation description XML string.

Note

Microsoft Chart Controls lets you create various types of charts such as column, bar, area, line, pie, funnel, bubble, and radar. The chart designer in Microsoft Dynamics 365 lets you create only certain types of charts. However, using the SDK, you can create most of the chart types that are supported by Microsoft Chart Controls.

Use the data description XML string to specify chart data

The data description XML string defines the data that will displayed on the chart. The contents of the XML string are validated against the visualization data description schema. For more information about the schema, see Visualization data description schema.

You can specify the data description XML string while you are creating a chart using the SavedQueryVisualization.DataDescription or the UserQueryVisualization.DataDescription attribute for the organization-owned or user-owned chart respectively.

The data description XML string contains the following two elements: <FetchCollection> and <CategoryCollection>.

The <FetchCollection> element

The <FetchCollection> element uses FetchXML to retrieve data for the chart. The FetchXML query specifies information about the entity attributes, aggregate functions, and the group by clauses for the data to be displayed in a chart. All the FetchXML aggregate functions are supported for charts. For more information about the FetchXML aggregate functions, see Use FetchXML aggregation.

The FetchXML query enables you to filter your data. Also, filters are applied on charts through views. Therefore, if a filter condition is already specified in the FetchXML query in the <FetchCollection> element, and additionally a filter is applied through a view, the chart will display data that is returned after it applies all the filters. For more information about how to use the FetchXML query to filter data, see Build queries with FetchXML.

Note

Although the data description XML string is validated again the visualization data description schema, the FetchXML query inside the <FetchCollection> element is not. The FetchXML query is validated against the FetchXML schema. For more information, see FetchXML schema.

If the chart is a comparison chart, the <FetchCollection> element will contain two group by clauses.

The <CategoryCollection> element

The <CategoryCollection> element contains information about the category (horizontal) and the series (vertical) axes in a chart.

  • Each <Category> sub-element has a child element called <MeasureCollection> that maps to the <Series> element in the presentation description XML. A single series chart has a single <MeasureCollection> child element whereas a multi-series chart will have multiple <MeasureCollection> child elements, each mapped to the respective <Series> element in the presentation description XML.

  • Each <MeasureCollection> child element has an element called <Measure> that corresponds to the series (vertical) axis value, corresponding to each value on the category (horizontal) axis.

Example

The following is a sample data description XML string:

<datadefinition>
  <fetchcollection>
    <fetch mapping="logical" count="10">
      <entity name="opportunity">
        <attribute name="estimatedvalue" />
        <order attribute="estimatedvalue" descending="true" />
      </entity>
    </fetch>
  </fetchcollection>
  <categorycollection>
    <category>
      <measurecollection>
        <measure alias="estimatedvalue" />
      </measurecollection>
    </category>
  </categorycollection></datadefinition>

For more sample data description XML strings, see Sample charts.

Use the presentation description XML string to specify data representation

The presentation description XML string contains information about the appearance of the chart such as chart title, chart color, and chart type (bar, column, line, and so on). There is no schema definition for this XML string. However, the XML is a serialization of the Chart class in Microsoft Chart Controls. More information:  Chart Controls

You can specify the presentation description XML string while you are creating a chart using the SavedQueryVisualization.PresentationDescription or UserQueryVisualization.PresentationDescription attribute for the organization-owned or user-owned chart, respectively.

Example

The following is a sample presentation description XML string:

<Chart Palette="BrightPastel">
  <Series>
    <Series _Template_="All" Color="153, 204, 255" BorderColor="164, 164, 164" BorderDashStyle="Solid" BorderWidth="1" ShadowColor="128, 128, 128, 128" ShadowOffset="1" IsValueShownAsLabel="true" Font="{0}, 6.75pt" BackGradientStyle="TopBottom" BackSecondaryColor="0, 102, 153" LabelForeColor="100, 100, 100" ChartType="Column">
      <SmartLabelStyle Enabled="True" />
      <Points />
    </Series>
  </Series>
  <ChartAreas>
    <ChartArea _Template_="All" BackColor="White" BorderColor="26, 59, 105" BorderWidth="0" BorderDashStyle="Solid">      <AxisY LineColor="204, 204, 204" TitleFont="{0}, 8pt, GdiCharSet=0" TitleForeColor="100, 100, 100" LabelAutoFitMaxFontSize="7" LabelAutoFitMinFontSize="7">
        <MajorTickMark LineColor="Gray" />
        <MajorGrid Enabled="false" />
        <LabelStyle Font="{0}, 6.75pt, GdiCharSet=0" ForeColor="100, 100, 100" />
      </AxisY>
      <AxisX LineColor="204, 204, 204" TitleFont="{0}, 8pt, GdiCharSet=0" TitleForeColor="100, 100, 100" LabelAutoFitMaxFontSize="7" LabelAutoFitMinFontSize="7">        <MajorTickMark LineColor="Gray" />        <MajorGrid Enabled="false" />
        <LabelStyle Font="{0}, 6.75pt, GdiCharSet=0" ForeColor="100, 100, 100" />
      </AxisX>
    </ChartArea>
  </ChartAreas>
  <Titles>
    <Title _Template_="All" Font="{0}, 9pt, style=Bold, GdiCharSet=0" ForeColor="100, 100, 100"></Title>
  </Titles>
  <BorderSkin PageColor="Control" BackColor="CornflowerBlue" BackSecondaryColor="CornflowerBlue" />
</Chart>

For more sample presentation description XML strings, see Sample charts.

See Also

View data with visualizations (charts)
Actions on visualizations (charts)
Create a visualization (chart)
Build queries with FetchXML
FetchXML schema
Visualization data description schema
Sample charts
Chart Class (Microsoft Chart Controls)

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright