Palisade Knowledge Base

HomeTechniques and Tips@RISK Simulation: Graphical ResultsCustom Color Selection in Graphs

7.22. Custom Color Selection in Graphs

Applies to: @RISK 6.2/6.3/7.x, Professional and Industrial Editions

I right-click a graph and select the Curves tab. When I try to change the color, the Define Custom Color button is grayed out. How do I unlock it?

That button is grayed out by design, but if you want a color different from the available colors you can create the graph in VBA. Please click Help » Developer Kit (XDK) » Automation Guide for a friendly introduction to controlling @RISK with VBA. The Automation Guide contains sample code for generating reports, though not for setting colors.

For setting colors specifically, you need the CurveColor method of the RiskGraph object. It's in the @RISK XDK Reference in the Help » Developer Kit (XDK) menu, but probably it's easier just to look at an example. Please take a look at the attached file, which is a modified form of our example spreadsheet found at Help » Developer Kit (XDK) » Examples » RISK XDK – Creating Graphs 2.xlsx. In this example, on the Model worksheet, click Run Simulation and then Distribution Graphs of Outputs. All of the graphs are placed on the Graphs1 worksheet, in a 5×4 array.

Press Alt+F11 to view the code, and look at the Graphs1 subroutine. Before calling the ImageToWorksheet method, use CurveColor to set the color of the curve. (CurveColor takes an index argument to let you use different colors when a graph contains more than one curve.) RGB is an Excel macro that lets you set red, green, and blue, in that order, to any value from 0 to 255 inclusive.

Last edited: 2015-08-25


This page was: Helpful | Not Helpful