How to: Format Chart Colors

Applies To: Microsoft Dynamics AX 2012 R2

The Microsoft Dynamics AX framework provides automatic chart formatting. You can use the default chart colors or specify the color specifically. You can specify the chart colors in the chart behavior properties or programmatically in the control class definition. For example, you could assign a color palette to charts based on what company data is displayed.

To Specify Chart Colors in Properties

  1. In your Visual Studio chart project, in design view, select the AxChartBehavior.

  2. In the Properties window, set the UseAXColors property to False.

  3. Click the Palette ellipsis button (…). The Palette Collection Editor opens.

  4. Click the Add button. A Microsoft.Dynamics.Framework.Portal.UI.WebControls.Palette member is added.

  5. Click the Color dropdown to select a color palette and then click OK.

  6. Click Save to update the color changes.

To Specify Chart Colors in Code

  1. In your Visual Studio chart project, in Solution Explorer, double-click the [ChartName].ascx.cs control class definition to open the class in code editor.

  2. The following code example will set the chart color to dark red.

    protected void Page_Load(object sender, EventArgs e)
        {
            // Set the AxChartBehavior to not use Microsoft Dynamics AX colors.
            this. MyAxChartBehavior.UseAXColors = false;
    
            // Set the color value of the palette.
            this.MyAxChartBehavior.Palette.Add(new Palette(ChartColors.RedDark));
        }

See also

Chart Controls Overview