Extends
The number of seconds between chart automatic refreshing. The initial value comes from the chart region Automatic Refresh: Interval attribute. See also the chartRegion#startAutoRefresh and chartRegion#stopAutoRefresh methods.
Note: Small values, such as 2 seconds, for this property are discouraged since they may cause serious database performance issues. The interval should be much longer than the time the ajax request to refresh the chart takes. Be sure to take server resources and expected number of clients into consideration.
The value must be 0 (to disable auto refresh) or greater than or equal to 1.
Type:
- number
- Default Value:
- 0
Example
See the example for chartRegion#startAutoRefresh.
The jQuery object for the region element.
Type:
- jQuery
- Inherited From:
Example
Get option element after initialization.
var value = apex.region( "myRegionId" ).element;
If false the initial chart data is generated by the server as part of the page and is shown as soon as the chart component is initialized. If true the client will request the initial data using ajax as soon as the chart component is initialized (unless chartRegion#manualLoading is true). The chart component is initialized when it is first visible (takes space in the DOM) and if chartRegion#lazyWhenIrrelevant is true when it is scrolled into view.
This is available as an option property in the chart region Initialization JavaScript Function attribute. The value comes from the chart region Performance: Lazy Loading attribute.
Type:
- boolean
Allows the chart region to be lazy about fetching data initially and during auto refresh (see chartRegion#autoRefreshInterval) if the region is irrelevant to the user according to the browser's CSS "content-visibility" "auto" setting. Typically, regions that are sufficiently outside the scrolling viewport are not relevant.
When true and chartRegion#lazyLoading is true and when the browser renders the page the chart is reasonably far outside the scrolling viewport, the chart will not be initialized (and also will not fetch initial data) until the chart is scrolled into view. When true and auto refresh is happening, the chart will not fetch any data while it is irrelevant (refreshing is paused).
Note: setting to true will add a small delay (depends on browser and page complexity but likely under 100ms) before the chart component is initialized so this should only be set to true for regions likely to be outside the initial viewport. I.e. charts towards the bottom of the page.
When false normal initialization and lazy loading apply.
This is available as an option property in the region Initialization JavaScript Function attribute.
Type:
- boolean
- Default Value:
- false
Example
On a long page with many regions there is a chart region that is very likely to be outside the scrolling viewport. To delay fetching data for this chart until it is scrolled into view, the following is added to Initialization JavaScript Function. This means that if the user never scrolls the chart into view the chart data is not fetched and the database is not queried, thus reducing load on the server.
function( options ) {
options.lazyWhenIrrelevant = true;
return options;
}
If true this region will not automatically fetch the initial data when the chart component is initialized. This allows fetching or otherwise providing the chart data by other means. For example using the apex.region.multipleRefresh function to fetch multiple charts with a single ajax request. If false normal lazy loading happens on page load. Only applies when chartRegion#lazyLoading is true.
This is available as an option property in the chart region Initialization JavaScript Function attribute.
Type:
- boolean
- Default Value:
- false
Example
In this example a page has 2 chart regions (HTML DOM ids "chart1" and "chart2") with complex SQL queries that take a while to process. Both charts have Lazy Loading on. To reduced load on the server the initial data for each chart is fetched in a single ajax request.
Both charts have Initialization JavaScript Function:
function( options ) {
options.manualLoading = true;
return options;
}
Then in a Page Load DA, Execute JavaScript Code action add this code:
apex.region.multipleRefresh(["chart1", "chart2"]);
The chartRegion type is "JetChart".
Type:
- string
- Overrides:
The widget name depends on the chart type. See the table in the chartRegion interface description.
Type:
- string
- Overrides:
This is used to call methods including getting and setting options on the JET widget associated with the chart region. The type of JET widget depends on the APEX Chart region type. See the table in the chartRegion interface description. See the JET documentation for details on the available methods and options (attributes).
Calling JET component methods before the component is ready will do nothing. However, you can get and set options before the component is ready.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
pMethod |
string | The string name of the widget method. | |
args |
* |
<repeatable> |
Any number of arguments to be passed to the widget method. |
- Overrides:
Returns:
- Type
- *
Examples
This example gets the values at the given x and y pixel coordinates.
let values = apex.region( "myLineChart" ).call( "getValuesAt", 90, 80 );
// do something with the values object x, y, and y2 properties.
This example gets the orientation option for the bar chart with HTML DOM id "myBar".
let orientation = apex.region( "myBar" ).call( "option", "orientation" );
// do something with orientation
This example sets the orientation option for the bar chart with HTML DOM id "myBar" to "horizontal".
apex.region( "myBar" ).call( "option", "orientation", "horizontal" );
Focus the chart.
- Overrides:
Example
Focus a chart region with HTML DOM id "myChart".
apex.region( "myChart" ).focus();
Returns true if the underlying JET component is initialized and ready to use.
See also chartRegion#whenReady.
Returns:
- Type
- boolean
Example
This code, which runs when a button is clicked, first checks if the JET chart is ready before setting the horizontal orientation. By checking first it avoids an exception if the user clicks the button before the JET chart has initialized. To keep the user from clicking the button see the example for chartRegion#whenReady.
let areaChart = apex.region( "myAreaChart" );
// make sure chart is ready, to avoid an exception (Another way is to use the call
// method which allows setting options before the component is ready.)
if ( areaChart.isReady() ) {
areaChart.widget().ojChart( "option", "orientation", "horizontal" );
}
// otherwise do nothing. The user will likely try to click the button again
Removes an event handler from the JET component element associated with this region. See the JET documentation for the events that the JET component supports.
See also chartRegion#on.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
events |
One or more space-separated event types and optional namespaces as defined by the
jQuery off method. |
||
args |
* |
<repeatable> |
Other arguments to be passed to the widget's jQuery object
off method such as selector, data, and handler. |
- Overrides:
Example
This removes the ojviewportchange event handler.
apex.region( "myStockChart" ).off( "ojviewportchange" );
Attaches an event handler to the JET component element associated with this region. See the JET documentation for the events that the JET component supports.
See also chartRegion#off.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
events |
One or more space-separated event types and optional namespaces as defined by the
jQuery on method. |
||
args |
* |
<repeatable> |
Other arguments to be passed to the widget's jQuery object
on method such as selector, data, and handler. |
- Overrides:
Example
On a stock chart that supports zoom and scroll this will handle viewport changes as the user zooms or scrolls.
apex.region( "myStockChart" ).on( "ojviewportchange", function( event, data ) {
console.log( "viewport changed", data.xMax, data.xMin );
// do something in response to viewport change event
} );
Refresh the data visualization with new data from the server. Does nothing if the chart control is not yet initialized. (See chartRegion#whenReady.)
When data is fetched from the server this will trigger the apex.event:apexbeforerefresh event before the data is refreshed and the apex.event:apexafterrefresh event after the data is refreshed.
- Overrides:
Returns:
- Type
- Promise | null
Example
Refresh a chart region with HTML DOM id "myChart". The server will return the current data for the chart region.
apex.region( "myChart" ).refresh();
Refreshes the data visualization without fetching new data from the server. Use this for example if the underlying series data on the client side has been changed programmatically.
Example
This example of a line chart doubles each of the first series values and then refreshes the line chart.
let s1 = apex.region( "myLineChart" ).call( "option", "series" )[0];
s1.items.forEach( item => {
item.value = item.value * 2;
item.label = item.label * 2;
} );
apex.region( "myLineChart" ).refreshView();
Starts automatically refreshing this chart every chartRegion#autoRefreshInterval seconds. The autoRefreshInterval must not be 0. The refreshing will pause if the browser window or tab or the chart region is hidden and will resume once it is visible again.
The refreshing can be stopped with chartRegion#stopAutoRefresh.
Example
Refresh the chart every 5 minutes while it is visible.
let chartRegion = apex.region( "myLineChart" );
chartRegion.autoRefreshInterval = 300; // 5 minutes
chartRegion.startAutoRefresh();
Stops automatically refreshing this chart if it was previously started with chartRegion#startAutoRefresh.
Example
Stop refreshing the chart.
apex.region( "myLineChart" ).stopAutoRefresh();
Returns a promise that resolves when the underlying JET component is initialized and ready to use. Note that a chartRegion is not initialized until it is first visible and the JET library has loaded. The data may not yet be loaded.
See also chartRegion#isReady.
Returns:
- Type
- Promise
Example
In this example a button with HTML DOM id "orientationButton" is initially disabled (with button attribute Show as Disabled = On or Custom Attribute = disabled). Then in a Page Load dynamic action this code will enable the button. This is another way to ensure a user clicking on a button as soon as the page loads doesn't cause an exception when that button calls a JET component API. Compare with chartRegion#isReady example.
apex.region("areaChart").whenReady().then( () => {
// now that areaChart is ready enable the button that sets the orientation
$( "#orientationButton" ).removeAttr( "disabled" );
} );
Returns the JET widget element associated with the chart region. The type of JET widget depends on the APEX Chart region type. See the table in the chartRegion interface description. If the intent is to use the widget interface it is better to use the chartRegion#call method.
- Overrides:
Returns:
- Type
- jQuery