Skip to content

Commit 962b13c

Browse files
authored
DOCSP-7953: [Charts] As a developer, I can programmatically refresh the chart embedded in my web page (#304)
1 parent 98879e5 commit 962b13c

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

source/embedding-charts-sdk.txt

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ The example app is configured with a chart ID and base URL which are
7676
particular to the app. Be sure to configure your own apps with the correct
7777
chart ID and base URL.
7878

79+
The example app uses two SDK methods:
80+
81+
.. list-table::
82+
:header-rows: 1
83+
:widths: 15 55 15 15
84+
85+
* - Method
86+
- Description
87+
- Args
88+
- Returns
89+
90+
* - ``refresh()``
91+
- Reloads the chart with the latest data from its
92+
:ref:`data source <data-sources>`.
93+
- none
94+
- Promise<void>
95+
96+
* - ``setFilter()``
97+
- Filters your embedded chart based on a specified MQL
98+
:ref:`filter document <query-bar>`.
99+
100+
.. note::
101+
102+
Any fields included in the filter must be specified in the Embed
103+
Chart modal. See :ref:`Filter Embedded Charts with the SDK
104+
<filter-embedded-sdk>`.
105+
106+
- :ref:`filter <query-bar>` object
107+
- Promise<void>
108+
79109
Quick Start with HTML
80110
~~~~~~~~~~~~~~~~~~~~~
81111

@@ -124,6 +154,8 @@ page by including it as part of a header script tag.
124154
</body>
125155
</html>
126156

157+
.. _filter-embedded-sdk:
158+
127159
Filter Embedded Charts with the SDK
128160
-----------------------------------
129161

@@ -132,9 +164,24 @@ with the ``filter`` option. Filtering allows the chart author to only display
132164
data in the embedded chart which matches a specified :abbr:`MQL (MongoDB
133165
Query Language)` filter.
134166

135-
Any fields included in the filter must be specified in the Embed Chart modal
136-
window. The Embed Chart modal window contains a dropdown menu of fields on
137-
which to allow filtering.
167+
Any fields included in the filter must be specified in the Embed Chart modal.
168+
The Embed Chart modal contains a dropdown menu of fields on
169+
which to allow filtering.
170+
171+
The following uses the ``filter`` option to represent only documents in
172+
which the ``total`` field is greater than ``100``:
173+
174+
.. code-block:: javascript
175+
176+
createChart({
177+
baseUrl: '<your-base-url>',
178+
chartId: '<your-chart-id>',
179+
width: 500,
180+
height: 500,
181+
filter: { "total": { "$gt": 100 } }
182+
})
183+
184+
138185

139186
Option Reference
140187
----------------
@@ -179,7 +226,7 @@ method:
179226
* - ``refreshInterval``
180227
- number
181228
- How often to refresh the chart, in seconds. The minimum refresh
182-
interval is 10 seconds. ``autorefresh`` is off By default.
229+
interval is 10 seconds. ``autorefresh`` is off by default.
183230
- no
184231

185232
* - ``theme``

0 commit comments

Comments
 (0)