Style class for describing a color.

Instances of Color, like all LCJS style classes, are immutable, meaning that its setters don't modify the actual object, but instead return a completely new modified object.

Color creation:

Create LCJS colors using any of the many available factories:

Color usage:

Watch out! A common misuse is to attempt styling components directly with color. Color is the lowest level style class in whole LCJS library, and is never used directly for styling components, instead it must be wrapped within a more descriptive style type. For example, SolidFill describes coloring with single, solid color.

Example usage:

Example 1, specifying chart title color using ColorRGBA and SolidFill

 ChartXY.setTitleFillStyle( new SolidFill({
color: ColorRGBA( 255, 0, 0 )
}) )

Example 2, specifying line series stroke style using ColorRGBA, SolidFill and SolidLine

 LineSeries.setStrokeStyle(new SolidLine({
thickness: 2,
fillStyle: new SolidFill({
color: ColorRGBA( 255, 0, 0 )
})
}))

Hierarchy

  • ColorRecord
    • Color

Properties

a: number

Alpha value from 0 to 1

b: number

Blue value from 0 to 1

g: number

Green value from 0 to 1

r: number

Red value from 0 to 1

Methods

  • Returns

    Value of alpha channel [0-255]

    Returns number

  • Returns

    Value of blue channel [0-255]

    Returns number

  • Returns a slightly darker version from a Color.

    Returns

    New Color object

    Returns Color

  • Returns

    Value of green channel [0-255]

    Returns number

  • Compute a highlighted version of this Color.

    Returns

    New Color object

    Returns Color

  • Returns a slightly lighter version from a Color.

    Returns

    New Color object

    Returns Color

  • Returns

    Value of red channel [0-255]

    Returns number

  • Creates a new color that is equal to this but with a certain alpha value

    Returns

    New Color object

    Parameters

    • alpha: number

      Value of alpha channel [0-255]

    Returns Color

  • Creates a new color that is equal to this but with a certain blue value

    Returns

    New Color object

    Parameters

    • blue: number

      Value of blue channel [0-255]

    Returns Color

  • Creates a new color that is equal to this but with a certain green value

    Returns

    New Color object

    Parameters

    • green: number

      Value of green channel [0-255]

    Returns Color

  • Creates a new color that is equal to this but with a certain red value

    Returns

    New Color object

    Parameters

    • red: number

      Value of red channel [0-255]

    Returns Color

  • Returns

    Color string in format acceptable by CSS

    Returns string