# Yahoo! UI Library

### profilerviewer 2.5.2

Yahoo! UI Library > profilerviewer > YAHOO.widget.ProfilerViewer

Show Private Show Protected

## 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.

Returns: `void`

#### _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.

Returns: `void`

#### _createProfilerViewerElement

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

Returns: `void`
  HTMLElement

#### _dataTableRenderHandler

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

Returns: `void`

#### _drawChartLegend

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

Returns: `void`

#### _getChartData

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

Returns: `void`

#### _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.

Returns: `void`

#### _getSeriesDef

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

Returns: `void`

#### _initChart

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

Returns: `void`

#### _initChartDOM

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

Returns: `void`

#### _initDataTable

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

Returns: `void`

#### _initLauncherDOM

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

Returns: `void`

#### _initViewerDOM

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

Returns: `void`

#### _refreshChart

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

Returns: `void`

#### _refreshDataTable

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

Returns: `void`

#### _render

`private void _render ( )`
Render the viewer canvas

Returns: `void`
  void

#### _setBusyState

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

Returns: `void`

#### _sizeChartCanvas

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

Returns: `void`

#### _sortedByChange

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

Returns: `void`

#### _thClickHandler

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

Returns: `void`

#### _toggleVisible

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

Returns: `void`
  void

#### getBodyEl

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

Returns: `void`
  HTMLElement

#### getChart

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

Returns: `void`
  YAHOO.widget.BarChart

#### getChartEl

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

Returns: `void`
  HTMLElement

#### getDataTable

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

Returns: `void`
  YAHOO.widget.DataTable

#### getHeadEl

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

Returns: `void`
  HTMLElement

#### getTableEl

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

Returns: `void`
  HTMLElement

#### hide

`private void hide ( )`
Hides the viewer canvas.

Returns: `void`
  void

#### initAttributes

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

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

Returns: `void`

#### refreshData

`void 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`
  void

#### show

`private void show ( )`
Shows the viewer canvas.

Returns: `void`
  void

#### toString

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

Returns: `void`
  String

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

`_registerHTMLAttr, addClass, addListener, appendChild, appendTo, fireQueue, getElementsByClassName, getElementsByTagName, getStyle, hasChildNodes, hasClass, initAttributes, insertBefore, on, removeChild, removeClass, 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 ( eventInfo )`
Fires when the value for the configuration attribute 'base' changes.

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

#### beforeBaseChange

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

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

#### beforeChartSeriesDefinitionsChange

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

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

#### beforeChartStyleChange

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

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

#### beforeFilterChange

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

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

#### beforeMaxChartFunctionsChange

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

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

#### beforeShowChartChange

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

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

#### beforeSortedByChange

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

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

#### beforeSwfUrlChange

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

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

#### beforeTableHeightChange

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

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

#### beforeVisibleChange

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

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

#### chartSeriesDefinitionsChange

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

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

#### chartStyleChange

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

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

#### filterChange

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

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

#### maxChartFunctionsChange

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

Parameters:
  `eventInfo <{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 ( eventInfo )`
Fires when the value for the configuration attribute 'showChart' changes.

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

#### sortedByChange

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

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

#### swfUrlChange

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

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

#### tableHeightChange

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

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

#### visibleChange

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

Parameters:
  `eventInfo <{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 `- obj`

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.
Default Value: {key:"total", dir:"yui-dt-desc"}

#### swfUrl `- object`

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 © 2007 Yahoo! Inc. All rights reserved.