Skip to content
Christabella edited this page Jun 15, 2017 · 2 revisions

The color object is a simple wrapper for determining complimenting colors. It contains a fill and a stroke color which can be applied to a series.

Constructor

dimple.color(fill, stroke, opacity) [code] - Create a new color object with a stroke color and a fill color, which can be applied to a series. It accepts the following parameters.

  • fill (Required): A color string to use as a primary color for a series. This can be any standard web color string. e.g. "white", "#FFFFFF", "rgb(255, 255, 255)" or "argb(0, 255, 255, 255)" will all render as white.

  • stroke (Optional): This can be specifically set to a color string as with fill above. This provides the secondary color for a series, for example the border of a bar in a bar chart. If not provided it will be automatically calculated by darkening the fill.

  • opacity (Optional): By default this is set to 80% opacity and it will be applied to both the fill and stroke for a shape to which this color is applied.

Example:

// Set a variety of default colors
myChart.defaultColors = [
	new dimple.color("#FF0000", "Blue"), // Set a red fill with a blue stroke
	new dimple.color("#00FF00"), // Set a green fill with a darker green stroke
	new dimple.color("rgb(0, 0, 255)") // Set a blue fill with a darker blue stroke
]; 

Properties

dimple.color.fill [code] - A color string to use as a primary color for a series. This can be any standard web color string. e.g. "white", "#FFFFFF", "rgb(255, 255, 255)" or "argb(0, 255, 255, 255)" will all render as white.

Example:

// Turn red fill to black
myColor = new dimple.color("FF0000");
myColor.fill = "black";

dimple.color.stroke [code] - This provides the secondary color for a series, for example the border of a bar in a bar chart.

Example:

// Create a red shape with a black fill
myColor = new dimple.color("FF0000");
myColor.stroke = "black";

dimple.color.opacity [code] - This provides the opacity of a series.

Example:

// Create a Semi-transparent red color series
myColor = new dimple.color("FF0000");
myColor.opacity = 0.5;
Clone this wiki locally