API: profilerviewer YAHOO.widget.ProfilerViewer (YUI Library)

# Yahoo! UI Library

### profilerviewer 2.8.2r1

Yahoo! UI Library > profilerviewer > YAHOO.widget.ProfilerViewer
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.widget.ProfilerViewer - extends YAHOO.util.Element

A widget to view YUI Profiler output.

### Constructor

YAHOO.widget.ProfilerViewer `( el(optional) , attr )`

Parameters:
  `el(optional) <HTMLElement | String | Object>` The html element into which the ProfileViewer should be rendered. An element will be created if none provided.
  `attr <Object>` (optional) A key map of the ProfilerViewer's initial attributes. Ignored if first arg is an attributes object.

### Properties

#### CLASS - `static string`

Classname for ProfilerViewer containing element.
Default Value: "yui-pv"

#### CLASS_BUSY - `static string`

Classname for busy indicator in the dashboard.
Default Value: "yui-pv-busy"

#### CLASS_CHART - `static string`

Classname for element containing the chart.
Default Value: "yui-pv-chart"

#### CLASS_CHART_CONTAINER - `static string`

Classname for element containing the chart and chart legend elements.
Default Value: "yui-pv-chartcontainer"

#### CLASS_CHART_LEGEND - `static string`

Classname for element containing the chart's legend.
Default Value: "yui-pv-chartlegend"

#### CLASS_DASHBOARD - `static string`

Classname for ProfilerViewer button dashboard.
Default Value: "yui-pv-dashboard"

#### CLASS_REFRESH - `static string`

Classname for the "refresh data" button.
Default Value: "yui-pv-refresh"

#### CLASS_TABLE - `static string`

Classname for element containing the datatable.
Default Value: "yui-pv-table"

#### percentAxisLabelFunction - `private static function`

Function used to format percent numbers for chart; must be publicly accessible, per Charts spec.

#### STRINGS - `static object`

Strings used in the UI.
Default Value: English language strings for UI.

#### timeAxisLabelFunction - `private static function`

Function used to format numbers in milliseconds for chart; must be publicly accessible, per Charts spec.

#### Properties inherited from YAHOO.util.Element:

`DOM_EVENTS`

#### Properties inherited from YAHOO.util.AttributeProvider:

`_configs`

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### _arraySum

`private void _arraySum ( )`
Utility function for array sums.

#### _createButton

`private void _createButton ( )`
Create anchor elements for use as buttons. Args: label is text to appear on the face of the button, parentEl is the el to which the anchor will be attached, position is true for inserting as the first node and false for inserting as the last node of the parentEl.

#### _createProfilerViewerElement

`private _createProfilerViewerElement ( )`
If no element is passed in, create it as the first element in the document.

Returns: ``
  HTMLElement

#### _dataTableRenderHandler

`private void _dataTableRenderHandler ( )`
Proxy the render event in DataTable into the ProfilerViewer attribute.

#### _drawChartLegend

`private void _drawChartLegend ( )`
Set up the Chart's legend

#### _getChartData

`private void _getChartData ( )`
Get data for the Chart from DataTable recordset

#### _getProfilerData

`private void _getProfilerData ( )`
Retrieves data from Profiler, filtering and sorting as needed based on current widget state. Adds calculated percentage column and function name to data returned by Profiler.

#### _getSeriesDef

`private void _getSeriesDef ( )`
Build series definition based on current configuration attributes.

#### _initChart

`private void _initChart ( )`
Set up the Chart.

#### _initChartDOM

`private void _initChartDOM ( )`
Set up the DOM structure for the ProfilerViewer canvas.

#### _initDataTable

`private void _initDataTable ( )`
Set up the DataTable.

#### _initLauncherDOM

`private void _initLauncherDOM ( )`
Set up the DOM structure for the ProfilerViewer launcher.

#### _initViewerDOM

`private void _initViewerDOM ( )`
Set up the DOM structure for the ProfilerViewer canvas, including the holder for the DataTable.

#### _refreshChart

`private void _refreshChart ( )`
Refresh chart, getting new data from table.

#### _refreshDataTable

`private void _refreshDataTable ( )`
Refresh DataTable, getting new data from Profiler.

#### _render

`private _render ( )`
Render the viewer canvas

Returns: ``
  void

#### _setBusyState

`private void _setBusyState ( )`
Set's console busy state.

#### _sizeChartCanvas

`private void _sizeChartCanvas ( )`
Resize the chart's canvas if based on number of records returned from the chart's datasource.

#### _sortedByChange

`private void _sortedByChange ( )`
Proxy the sort event in DataTable into the ProfilerViewer attribute.

#### _thClickHandler

`private void _thClickHandler ( )`
Event handler for clicks on the DataTable's sortable column heads.

#### _toggleVisible

`private _toggleVisible ( )`
Toggles visibility of the viewer canvas.

Returns: ``
  void

#### getBodyEl

`getBodyEl ( )`
Returns the element containing the console's body, including the chart and the datatable..

Returns: ``
  HTMLElement

#### getChart

`getChart ( )`
Returns the element containing the console's Chart instance.

Returns: ``
  YAHOO.widget.BarChart

#### getChartEl

`getChartEl ( )`
Returns the element containing the console's chart.

Returns: ``
  HTMLElement

#### getDataTable

`getDataTable ( )`
Returns the element containing the console's DataTable instance.

Returns: ``
  YAHOO.widget.DataTable

#### getHeadEl

`getHeadEl ( )`
Returns the element containing the console's header.

Returns: ``
  HTMLElement

#### getTableEl

`getTableEl ( )`
Returns the element containing the console's dataTable.

Returns: ``
  HTMLElement

#### hide

`private hide ( )`
Hides the viewer canvas.

Returns: ``
  void

#### initAttributes

`private void initAttributes ( attr )`
setAttributeConfigs TabView specific properties.

Parameters:
  `attr <Object>` Hash of initial attributes

#### refreshData

`refreshData ( )`
Refreshes the data displayed in the ProfilerViewer. When called, this will invoke a refresh of the DataTable and (if displayed) the Chart.

Returns: ``
  void

#### show

`private show ( )`
Shows the viewer canvas.

Returns: ``
  void

#### toString

`private toString ( )`
Provides a readable name for the ProfilerViewer instance.

Returns: ``
  String

#### Methods inherited from YAHOO.util.Element:

`_setHTMLAttrConfig, addClass, addListener, appendChild, appendTo, delegate, fireQueue, getElementsByClassName, getElementsByTagName, getStyle, hasChildNodes, hasClass, initAttributes, insertBefore, on, removeChild, removeClass, removeDelegate, removeListener, replaceChild, replaceClass, setStyle, subscribe`

#### Methods inherited from YAHOO.util.AttributeProvider:

`configureAttribute, fireBeforeChangeEvent, fireChangeEvent, get, getAttributeConfig, getAttributeKeys, refresh, register, resetAttributeConfig, resetValue, set, setAttributeConfig, setAttributes`

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### baseChange

`baseChange ( event )`
Fires when the value for the configuration attribute 'base' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeBaseChange

`beforeBaseChange ( event )`
Fires before the value for the configuration attribute 'base' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeChartSeriesDefinitionsChange

`beforeChartSeriesDefinitionsChange ( event )`
Fires before the value for the configuration attribute 'chartSeriesDefinitions' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeChartStyleChange

`beforeChartStyleChange ( event )`
Fires before the value for the configuration attribute 'chartStyle' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeFilterChange

`beforeFilterChange ( event )`
Fires before the value for the configuration attribute 'filter' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeMaxChartFunctionsChange

`beforeMaxChartFunctionsChange ( event )`
Fires before the value for the configuration attribute 'maxChartFunctions' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeShowChartChange

`beforeShowChartChange ( event )`
Fires before the value for the configuration attribute 'showChart' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeSortedByChange

`beforeSortedByChange ( event )`
Fires before the value for the configuration attribute 'sortedBy' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeSwfUrlChange

`beforeSwfUrlChange ( event )`
Fires before the value for the configuration attribute 'swfUrl' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeTableHeightChange

`beforeTableHeightChange ( event )`
Fires before the value for the configuration attribute 'tableHeight' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### beforeVisibleChange

`beforeVisibleChange ( event )`
Fires before the value for the configuration attribute 'visible' changes. Return false to cancel the attribute change.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### chartSeriesDefinitionsChange

`chartSeriesDefinitionsChange ( event )`
Fires when the value for the configuration attribute 'chartSeriesDefinitions' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### chartStyleChange

`chartStyleChange ( event )`
Fires when the value for the configuration attribute 'chartStyle' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### filterChange

`filterChange ( event )`
Fires when the value for the configuration attribute 'filter' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### maxChartFunctionsChange

`maxChartFunctionsChange ( event )`
Fires when the value for the configuration attribute 'maxChartFunctions' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### refreshDataEvent

`refreshDataEvent ( )`
Fired when a data refresh is requested. No arguments are passed with this event.

#### renderEvent

`renderEvent ( )`
Fired when the viewer canvas first renders. No arguments are passed with this event.

#### showChartChange

`showChartChange ( event )`
Fires when the value for the configuration attribute 'showChart' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### sortedByChange

`sortedByChange ( event )`
Fires when the value for the configuration attribute 'sortedBy' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### swfUrlChange

`swfUrlChange ( event )`
Fires when the value for the configuration attribute 'swfUrl' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### tableHeightChange

`tableHeightChange ( event )`
Fires when the value for the configuration attribute 'tableHeight' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### visibleChange

`visibleChange ( event )`
Fires when the value for the configuration attribute 'visible' changes.

Parameters:
  `event <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### Events inherited from YAHOO.util.Element:

`appendTo, available, beforeAppendTo, beforeElementChange, contentReady, elementChange,`

### Configuration Attributes

#### base `- string`

The YUI Loader base path from which to pull YUI files needed in the rendering of the ProfilerViewer canvas. Passed directly to YUI Loader. Leave blank to draw files from yui.yahooapis.com.
Default Value: ""

#### chartSeriesDefinitions `- obj`

The series definition information to use when charting specific fields on the chart. displayName, xField, and style members are used to construct the series definition; the "group" member is the array of fields that should be charted when the table is sorted by a given field.
Default Value: See JS source for full default definitions.

#### chartStyle `- obj`

The style object that defines the chart's visual presentation. Conforms to the style attribute passed to the Charts Control constructor. See Charts Control User's Guide for more information on how to format this object.
Default Value: See JS source for default definitions.

#### filter `- function`

A filter function to use in selecting functions that will appear in the ProfilerViewer report. The function is passed a function report object and should return a boolean indicating whether that function should be included in the ProfilerViewer display. The argument is structured as follows: { fn: , calls : , avg : , max: , min: , total: points : } For example, you would use the follwing filter function to return only functions that have been called at least once: function(o) { return (o.calls > 0); }
Default Value: null

#### maxChartFunctions `- int`

The maximum number of functions to profile in the chart. The greater the number of functions, the greater the height of the chart canvas. height.
Default Value: 6

#### showChart `- boolean`

The default visibility setting for the chart.
Default Value: true

#### sortedBy `- string`

The default column key to sort by. Valid keys are: fn, calls, avg, min, max, total. Valid dir values are: YAHOO.widget.DataTable.CLASS_ASC and YAHOO.widget.DataTable.CLASS_DESC (or their string equivalents).
Default Value: {key:"total", dir:"yui-dt-desc"}

#### swfUrl `- string`

The path to the YUI Charts swf file; must be a full URI or a path relative to the page being profiled. Changes at runtime not supported; pass this value in at instantiation.
Default Value: "http://yui.yahooapis.com/2.5.0/build/charts/assets/charts.swf"

#### tableHeight `- string`

The height of the DataTable. The table will scroll vertically if the content overflows the specified height.
Default Value: "15em"

#### visible `- boolean`

The default visibility setting for the viewer canvas. If true, the viewer will load all necessary files and render itself immediately upon instantiation; otherwise, the viewer will load only minimal resources until the user toggles visibility via the UI.
Default Value: false

#### Configuration attributes inherited from YAHOO.util.Element:

`element`

Copyright © 2010 Yahoo! Inc. All rights reserved.