Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color<TProps>

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 )
     })
 }))

Index

Methods

getA

  • getA(): number
  • Returns number

    Value of alpha channel [0-255]

getB

  • getB(): number
  • Returns number

    Value of blue channel [0-255]

getDarker

  • Returns a slightly darker version from a Color.

    Returns Color

    New Color object

getG

  • getG(): number
  • Returns number

    Value of green channel [0-255]

getHighlight

  • Compute a highlighted version of this Color.

    Returns Color

    New Color object

getLighter

  • Returns a slightly lighter version from a Color.

    Returns Color

    New Color object

getR

  • getR(): number
  • Returns number

    Value of red channel [0-255]

setA

  • setA(alpha: number): Color
  • Creates a new color that is equal to this but with a certain alpha value

    Parameters

    • alpha: number

      Value of alpha channel [0-255]

    Returns Color

    New Color object

setB

  • setB(blue: number): Color
  • Creates a new color that is equal to this but with a certain blue value

    Parameters

    • blue: number

      Value of blue channel [0-255]

    Returns Color

    New Color object

setG

  • setG(green: number): Color
  • Creates a new color that is equal to this but with a certain green value

    Parameters

    • green: number

      Value of green channel [0-255]

    Returns Color

    New Color object

setR

  • setR(red: number): Color
  • Creates a new color that is equal to this but with a certain red value

    Parameters

    • red: number

      Value of red channel [0-255]

    Returns Color

    New Color object

Static Factory

  • Factory(values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>
  • Type parameters

    • TProps: Object

    Parameters

    • values: Partial<TProps> | Iterable<[string, any]>

    Returns Record<TProps> & Readonly<TProps>

Static Record

  • Record(defaultValues: TProps, name?: undefined | string): Factory<TProps>
  • Unlike other types in Immutable.js, the Record() function creates a new Record Factory, which is a function that creates Record instances.

    See above for examples of using Record().

    Note: Record is a factory function and not a class, and does not use the new keyword during construction.

    Type parameters

    • TProps

    Parameters

    • defaultValues: TProps
    • name: undefined | string

    Returns Factory<TProps>

Static getDescriptiveName

  • getDescriptiveName(record: Record<any>): string
  • Records allow passing a second parameter to supply a descriptive name that appears when converting a Record to a string or in any error messages. A descriptive name for any record can be accessed by using this method. If one was not provided, the string "Record" is returned.

    const { Record } = require('immutable')
    const Person = Record({
      name: null
    }, 'Person')
    
    var me = Person({ name: 'My Name' })
    me.toString() // "Person { "name": "My Name" }"
    Record.getDescriptiveName(me) // "Person"

    Parameters

    Returns string

Static isRecord

  • isRecord(maybeRecord: any): maybeRecord
  • True if maybeRecord is an instance of a Record.

    Parameters

    • maybeRecord: any

    Returns maybeRecord