Skip to content

Latest commit

 

History

History
 
 

doc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

xStats.js v1.0.0-pre

xStats

xStats.prototype

xStats.prototype.fps

xStats.prototype.mem

xStats.prototype.ms

xStats.Event

xStats.Event.prototype

xStats

xStats([options={}])

#

The xStats constructor.

Arguments

  1. [options={}] (Object): Options object.

Example

// basic usage (the `new` operator is optional)
var stats = new xStats;

// or using options
var stats = new xStats({
  'mode': 'ms',
  'height': 130,
  'width':200,
  'padding':10,
  'locked': false,
  'fps': {
    'bg': '#330000',
    'fg': '#cc6600'
  },
  'ms': {
    'bg': '#000033',
    'fg': '#3366ff'
  },
  'mem': {
    'bg': '#000033',
    'fg': '#660099'
  }
});

// insert into document
document.body.appendChild(stats.element);

xStats.subclasses

#

(Array): An array of xStat instances.


xStats.prototype

xStats.prototype.height

#

(Number): The height of the chart (px).


xStats.prototype.locked

#

(Boolean): A flag to indicate if the chart is locked at its current display mode.


xStats.prototype.mode

#

(String): The charts current display mode (fps, ms, mem).


xStats.prototype.padding

#

(Number): The inner padding of the chart that doesn't affect dimensions (px).


xStats.prototype.sampleRate

#

(Number): The rate at which the "sample" event is emitted (secs).


xStats.prototype.width

#

(Number): The width of the chart (px).


xStats.prototype.addListener(type, listener)

#

Registers a single listener for the specified event type(s).

Arguments

  1. type (String): The event type.
  2. listener (Function): The function called when the event occurs.

Returns

(Object): The xStats instance.

Example

// register a listener for an event type
xs.addListener('sample', listener);

// register a listener for multiple event types
xs.addListener('start sample', listener);

xStats.prototype.emit(type)

#

Executes all registered listeners of the specified event type.

Arguments

  1. type (String|Object): The event type or object.

Returns

(Boolean): Returns true if all listeners were executed, else false.


xStats.prototype.on

#

Alias of xStats#addListener.


xStats.prototype.removeAllListeners(type)

#

Unregisters all listeners or those for the specified event type(s).

Arguments

  1. type (String): The event type.

Returns

(Object): The xStats instance.

Example

// unregister all listeners
xs.removeAllListeners();

// unregister all listeners for an event type
xs.removeAllListeners('sample');

// unregister all listeners for multiple event types
xs.removeAllListeners('start sample complete');

xStats.prototype.removeListener(type, listener)

#

Unregisters a single listener for the specified event type(s).

Arguments

  1. type (String): The event type.
  2. listener (Function): The function to unregister.

Returns

(Object): The xStats instance.

Example

// unregister a listener for an event type
xs.removeListener('sample', listener);

// unregister a listener for multiple event types
xs.removeListener('start sample', listener);

xStats.prototype.fps

xStats.prototype.fps

#

(Object): The "frames per second" display mode options object.


xStats.prototype.fps.bg

#

(String): The background color of the chart for the display mode.


xStats.prototype.fps.fg

#

(String): The foreground color of the chart for the display mode.


xStats.prototype.mem

xStats.prototype.mem

#

(Object): The "memory" display mode options object.


xStats.prototype.mem.bg

#

(String): The background color of the chart for the display mode.


xStats.prototype.mem.fg

#

(String): The foreground color of the chart for the display mode.


xStats.prototype.ms

xStats.prototype.ms

#

(Object): The "millisecond" display mode options object.


xStats.prototype.ms.bg

#

(String): The background color of the chart for the display mode.


xStats.prototype.ms.fg

#

(String): The foreground color of the chart for the display mode.


xStats.Event

xStats.Event(type)

#

The Event constructor.

Arguments

  1. type (String|Object): The event type.

xStats.Event.prototype

xStats.Event.prototype.type

#

(String): The event type.