@@ -13,7 +13,7 @@ Embedded Chart Options
1313 :class: singlecol
1414
1515You can customize the appearance and behavior your embedded charts with a
16- variety of options. Options are avaiable to charts charts embedded with the
16+ variety of options. Options are available to charts charts embedded with the
1717:ref:`Embedding SDK <embedding-charts-sdk>` and embedded within :ref:`iframes
1818<embedding-charts-iframe>`.
1919
@@ -49,8 +49,7 @@ variety of options. Options are avaiable to charts charts embedded with the
4949 chartId: "8d4dff93-e7ca-4ccd-a622-e20e8a100197",
5050 baseUrl: "https://charts.mongodb.com/charts-embedding-examples-hmewt",
5151 height: 300,
52- width: 400,
53- refreshInterval: 300
52+ width: 400
5453 });
5554
5655 The following options are available to ``createChart``:
@@ -93,10 +92,27 @@ variety of options. Options are avaiable to charts charts embedded with the
9392 - A :ref:`filter <embed-options-filter>` to apply to the chart.
9493 - no
9594
96- * - ``refreshInterval``
95+ * - ``autoRefresh``
96+ - boolean
97+ - Specifies whether the chart automatically refreshes. If
98+ omitted, charts do not automatically refresh.
99+
100+ Use this option with the ``maxDataAge`` option to
101+ configure how often the chart refreshes.
102+ - no
103+
104+ * - ``maxDataAge``
97105 - number
98- - How often to refresh the chart, in seconds. The minimum refresh
99- interval is 10 seconds. ``autorefresh`` is off by default.
106+ - Specifies the maximum age of data to load from the cache
107+ when loading or refreshing the chart. If omitted,
108+ |charts| renders the chart with data from the cache if
109+ the data is less than one hour old.
110+
111+ To learn how |charts| loads data from the cache when
112+ loading or refreshing the chart based on the
113+ ``autoRefresh`` and ``maxDataAge`` values, see
114+ :ref:`auto-refresh-behavior`.
115+
100116 - no
101117
102118 * - ``theme``
@@ -164,12 +180,14 @@ variety of options. Options are avaiable to charts charts embedded with the
164180 .. example::
165181
166182 The following code snippets set the theme of a Chart instance named
167- ``chart`` to ``dark`` and its refresh interval to 30 seconds.
183+ ``chart`` to ``dark`` and it to refresh automatically every
184+ 30 seconds.
168185
169186 .. code-block:: javascript
170187
171188 chart.setTheme("dark");
172- chart.setRefreshInterval(30);
189+ chart.setAutoRefresh(true);
190+ chart.setMaxDataAge(30);
173191
174192 .. list-table::
175193 :header-rows: 1
@@ -178,9 +196,23 @@ variety of options. Options are avaiable to charts charts embedded with the
178196 * - Method
179197 - Description
180198
181- * - ``setRefreshInterval(seconds: number)``
182- - Sets how long the embedded chart waits before refreshing.
183- The minimum interval is 10 seconds. To disable, set to 0.
199+ * - ``setAutoRefresh``
200+ - Specifies whether the chart automatically refreshes. If
201+ omitted, charts do not automatically refresh.
202+
203+ Use this method with the ``setMaxDataAge`` method to
204+ configure how often the chart refreshes.
205+
206+ * - ``setMaxDataAge``
207+ - Specifies the maximum age of data to load from the cache
208+ when loading or refreshing the chart. If omitted,
209+ |charts| renders the chart with data from the cache if
210+ the data is less than one hour old.
211+
212+ To learn how |charts| loads data from the cache when
213+ loading or refreshing the chart based on the
214+ ``setAutoRefresh`` and ``setMaxDataAge`` values, see
215+ :ref:`auto-refresh-behavior`.
184216
185217 * - ``setFilter(filter: object)``
186218 - Applies a :ref:`query filter <filter-embedded-charts>` to the
@@ -197,7 +229,7 @@ variety of options. Options are avaiable to charts charts embedded with the
197229 - Sets the current theme of the embedded chart. When setting the
198230 theme to ``dark``, you need to ensure that your chart's
199231 background color has appropriate contrast so that the information
200- remains visible. By default, a chart's background is transparent.
232+ remains visible.
201233
202234 .. seealso::
203235
@@ -217,58 +249,75 @@ variety of options. Options are avaiable to charts charts embedded with the
217249 specify a refresh interval for your chart, as well as a light or
218250 dark display theme.
219251
220- Specify a Refresh Interval
221- --------------------------
252+ Configure Auto Refresh and Data Caching Behavior
253+ ------------------------------------------------
254+
255+ Use the ``autorefresh`` query parameter to configure the chart
256+ to refresh automatically.
222257
223- Use the ``autorefresh`` query parameter to define the interval,
224- in seconds, at which the chart refreshes with the latest data from
225- its :ref:`data source <data-sources>`. Use the options on the
226- :guilabel:`Unauthenticated` tab on the :guilabel:`Embed Chart` dialog
227- to customize the ``autorefresh`` value in the iframe snippet.
258+ Use the ``maxDataAge`` query parameter to:
228259
229- If you do not specify the ``autorefresh`` option, your embedded chart
230- loads once when the iframe loads and does not automatically refresh.
260+ - Determine the interval at which the chart refreshes if
261+ ``autorefresh`` is ``true``.
262+ - Configure the maximum age of data to load from the cache when
263+ loading or manually refreshing the chart if ``autorefresh``
264+ is ``false`` or omitted.
265+
266+ To learn how |charts| loads data from the cache when loading
267+ or refreshing the chart based on the ``autorefresh`` and
268+ ``maxDataAge`` values, see :ref:`auto-refresh-behavior`.
269+
270+ Use the options on the
271+ :guilabel:`Unauthenticated` tab on the :guilabel:`Embed Chart`
272+ dialog to customize the ``autorefresh`` value in the iframe
273+ snippet.
231274
232275 Example
233276 ~~~~~~~
234277
235- The following iframe embeds a chart which automatically refreshes
236- every 30 seconds as defined by the ``autorefresh=30`` query parameter:
278+ The following iframe embeds a chart which automatically
279+ refreshes every 30 seconds as defined by the
280+ ``autorefresh=true`` and the ``maxDataAge=30`` query
281+ parameters:
237282
238283 .. code-block:: html
239284
240285 <iframe style="border: none;border-radius: 2px;box-shadow: 0 2px
241286 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="
242287 {charts-host}/embed/charts?id=b3ca720f-4b4a-40b4-a726-e7dc0c49aa1c&
243- autorefresh=30"></iframe>
288+ autorefresh=true&maxDataAge= 30"></iframe>
244289
245290 Considerations
246291 ~~~~~~~~~~~~~~
247292
248- - The minimum automatic refresh interval is 10 seconds. If you specify
249- an ``autorefresh `` value less than 10, the chart refreshes every 10
250- seconds.
293+ - The minimum cache duration is 10 seconds. If ``autorefresh``
294+ is ``true `` and you specify a ``maxDataAge`` value less than
295+ 10, the chart refreshes every 10 seconds.
251296
252- - If you specify an ``autorefresh`` value which is not an integer or
253- less than 0, an :ref:`error <embedded-errors>` is returned.
297+ - If you specify an ``maxDataAge`` value which is not an
298+ integer or less than ``-1``, an :ref:`error
299+ <embedded-errors>` is returned.
254300
255301 - If your data source requires a
256- :ref:`Verified Signature <embed-with-iframe-procedure>`, the signature
257- validity (including the expiry date) is checked on each refresh. If
258- the signature's expiry date passed, the host web page must
259- regenerate a new signature to continue rendering charts. For
260- code examples using verified signatures, see
261- `MongoDB Charts Embedding Examples <https://github.com/mongodb/charts-embedding-examples>`__
302+ :ref:`Verified Signature <embed-with-iframe-procedure>`, the
303+ signature validity (including the expiry date) is checked on
304+ each refresh. If the signature's expiry date passed, the host
305+ web page must regenerate a new signature to continue
306+ rendering charts. For code examples using verified
307+ signatures, see
308+ `MongoDB Charts Embedding Examples
309+ <https://github.com/mongodb/ charts-embedding-examples>`__
262310 on GitHub.
263311
264312 .. example::
265313
266- If you specify an automatic refresh interval of one minute and the
267- expiry date of the signature is in 1 hour, the chart refreshes
268- every minute for an hour. Once one hour has elapsed, the chart
269- will not render and an error will be displayed as the signature is
270- no longer valid. The host web page must regenerate a new signature
271- to resume rendering the chart.
314+ If ``autorefresh`` is ``true``, the cache duration is one
315+ minute (``maxDataAge=60``), and the expiry date of the
316+ signature is in one hour, the chart refreshes every minute
317+ for an hour. Once one hour has elapsed, the chart will not
318+ render and an error will be displayed as the signature is
319+ no longer valid. The host web page must regenerate a new
320+ signature to resume rendering the chart.
272321
273322 Specify a Display Theme
274323 -----------------------
@@ -323,9 +372,17 @@ variety of options. Options are avaiable to charts charts embedded with the
323372 <https://developer.mozilla.org/en-US/docs/Web/CSS/background>`__
324373 in the MDN Web Docs for more information.
325374
326- - Remove the ``background`` property to display the chart with a
327- transparent background, allowing your application's background to
375+ - Change the ``background`` property to ``transparent`` to
376+ display the chart with a transparent background, allowing
377+ your application's background to
328378 display through the chart.
379+
380+ - Remove the ``background`` property to use the default
381+ background color of the theme you choose:
382+
383+ - ``#FFFFFF`` for the ``light`` theme (default), or
384+
385+ - ``#21313C`` for the ``dark`` theme.
329386
330387 Chart Border
331388 ~~~~~~~~~~~~
@@ -413,4 +470,32 @@ variety of options. Options are avaiable to charts charts embedded with the
413470 theme=light&
414471 attribution=false
415472 "></iframe>
416-
473+
474+ .. _auto-refresh-behavior:
475+
476+ Auto Refresh and Data Caching Behavior
477+ --------------------------------------
478+
479+ The following table describes how |charts| loads data from the cache
480+ when loading or refreshing the chart based on the ``autorefresh`` or
481+ ``autoRefresh`` and ``maxDataAge`` values.
482+
483+ .. note::
484+
485+ The casing of the ``autoRefresh`` option differs based on whether
486+ you embed a chart using the Embedding SDK or an iframe:
487+
488+ .. list-table::
489+ :header-rows: 1
490+ :widths: 50 50
491+
492+ * - Embedding Method
493+ - Auto Refresh Option
494+
495+ * - Embedding SDK
496+ - ``autoRefresh``
497+
498+ * - iframe
499+ - ``autorefresh``
500+
501+ .. include:: /includes/autorefresh-maxdataage-values.rst
0 commit comments