@@ -19,107 +19,6 @@ query parameters to their iframe URLs.
19
19
options on your data sources. For instructions, see
20
20
:ref:`embedding-charts`.
21
21
22
- Query Parameter Order for Verified Signatures
23
- ---------------------------------------------
24
-
25
- If you are using a :ref:`Verified Signature <embedding-procedure>` to
26
- render your chart, you must specify the query parameters of your
27
- payload in the following order, or else your signature verification
28
- will fail:
29
-
30
- .. list-table::
31
- :header-rows: 1
32
- :widths: 10 20 40
33
-
34
- * - Parameter Position
35
- - Name
36
- - Description
37
-
38
- * - 1
39
- - ``id``
40
- - ``id`` parameter from the Embed Chart snippet.
41
-
42
- * - 2
43
- - ``tenant``
44
- - ``tenant`` parameter from the Embed Chart snippet.
45
-
46
- * - 3
47
- - ``timestamp``
48
- - Current time.
49
-
50
- * - 4
51
- - ``expires-in``
52
- - *(Optional)* Number of seconds for which the signature is valid.
53
- If omitted, the signature is valid for 24 hours after it is
54
- created.
55
-
56
- * - 5
57
- - ``filter``
58
- - *(Optional)* MQL document to filter rendered documents.
59
- See :ref:`embed-options-filter`.
60
-
61
- * - 6
62
- - ``autorefresh``
63
- - *(Optional)* Interval in seconds at which the chart refreshes.
64
- See :ref:`embed-options-refresh`.
65
-
66
- The code examples on the
67
- `MongoDB Charts Embedding Examples <https://github.com/mongodb/charts-embedding-examples>`__
68
- GitHub page provide sample payload generations with properly-formatted
69
- query parameters.
70
-
71
- .. _embed-options-refresh:
72
-
73
- Specify a Refresh Interval
74
- --------------------------
75
-
76
- Use the ``autorefresh`` query parameter to define the interval,
77
- in seconds, at which the chart refreshes with the latest data from
78
- its :ref:`data source <data-sources>`. If you do not specify
79
- this option, your embedded chart loads once when the iframe
80
- loads and does not automatically refresh.
81
-
82
- Example
83
- ~~~~~~~
84
-
85
- The following iframe embeds a chart which automatically refreshes
86
- every 30 seconds as defined by the ``autorefresh=30`` query parameter:
87
-
88
- .. code-block:: html
89
-
90
- <iframe style="border: none;border-radius: 2px;box-shadow: 0 2px
91
- 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="
92
- {charts-host}/embed/charts?id=b3ca720f-4b4a-40b4-a726-e7dc0c49aa1c&
93
- tenant=c184f559-a6d6-4c17-a524-fde31193e498&autorefresh=30"></iframe>
94
-
95
- Considerations
96
- ~~~~~~~~~~~~~~
97
-
98
- - The minimum automatic refresh interval is 10 seconds. If you specify
99
- an ``autorefresh`` value less than 10, the chart refreshes every 10
100
- seconds.
101
-
102
- - If you specify an ``autorefresh`` value which is not an integer or
103
- less than 0, an :ref:`error <embedded-errors>` is returned.
104
-
105
- - If your data source requires a
106
- :ref:`Verified Signature <embedding-procedure>`, the signature
107
- validity (including the expiry date) is checked on each refresh. If
108
- the signature's expiry date passed, the host web page must
109
- regenerate a new signature to continue rendering charts. For
110
- code examples using verified signatures, see
111
- `MongoDB Charts Embedding Examples <https://github.com/mongodb/charts-embedding-examples>`__
112
- on GitHub.
113
-
114
- .. example::
115
-
116
- If you specify an automatic refresh interval of one minute and the
117
- expiry date of the signature is in 1 hour, the chart refreshes
118
- every minute for an hour. Once one hour has elapsed, the chart
119
- will not render and an error will be displayed as the signature is
120
- no longer valid. The host web page must regenerate a new signature
121
- to resume rendering the chart.
122
-
123
22
.. _embed-options-filter:
124
23
125
24
Specify a Filter
@@ -193,3 +92,164 @@ filter is:
193
92
The server-side code creates a payload with the necessary information
194
93
to render the chart, including the filter. The payload ensures that
195
94
the verified signature is valid before rendering the chart.
95
+
96
+ .. _embed-options-refresh:
97
+
98
+ Specify a Refresh Interval
99
+ --------------------------
100
+
101
+ Use the ``autorefresh`` query parameter to define the interval,
102
+ in seconds, at which the chart refreshes with the latest data from
103
+ its :ref:`data source <data-sources>`. Use the options on the
104
+ :guilabel:`Unauthenticated` tab on the :guilabel:`Embed Chart` dialog
105
+ to customize the ``autorefresh`` value in the iframe snippet.
106
+
107
+ If you do not specify the ``autorefresh`` option, your embedded chart
108
+ loads once when the iframe loads and does not automatically refresh.
109
+
110
+ Example
111
+ ~~~~~~~
112
+
113
+ The following iframe embeds a chart which automatically refreshes
114
+ every 30 seconds as defined by the ``autorefresh=30`` query parameter:
115
+
116
+ .. code-block:: html
117
+
118
+ <iframe style="border: none;border-radius: 2px;box-shadow: 0 2px
119
+ 10px 0 rgba(70, 76, 79, .2);" width="640" height="480" src="
120
+ {charts-host}/embed/charts?id=b3ca720f-4b4a-40b4-a726-e7dc0c49aa1c&
121
+ tenant=c184f559-a6d6-4c17-a524-fde31193e498&autorefresh=30"></iframe>
122
+
123
+ Considerations
124
+ ~~~~~~~~~~~~~~
125
+
126
+ - The minimum automatic refresh interval is 10 seconds. If you specify
127
+ an ``autorefresh`` value less than 10, the chart refreshes every 10
128
+ seconds.
129
+
130
+ - If you specify an ``autorefresh`` value which is not an integer or
131
+ less than 0, an :ref:`error <embedded-errors>` is returned.
132
+
133
+ - If your data source requires a
134
+ :ref:`Verified Signature <embedding-procedure>`, the signature
135
+ validity (including the expiry date) is checked on each refresh. If
136
+ the signature's expiry date passed, the host web page must
137
+ regenerate a new signature to continue rendering charts. For
138
+ code examples using verified signatures, see
139
+ `MongoDB Charts Embedding Examples <https://github.com/mongodb/charts-embedding-examples>`__
140
+ on GitHub.
141
+
142
+ .. example::
143
+
144
+ If you specify an automatic refresh interval of one minute and the
145
+ expiry date of the signature is in 1 hour, the chart refreshes
146
+ every minute for an hour. Once one hour has elapsed, the chart
147
+ will not render and an error will be displayed as the signature is
148
+ no longer valid. The host web page must regenerate a new signature
149
+ to resume rendering the chart.
150
+
151
+ Specify a Display Theme
152
+ -----------------------
153
+
154
+ Use the ``theme`` query parameter to select a display theme:
155
+
156
+ - ``light``: chart axes and text are optimized for presentation against
157
+ a light or white background.
158
+ - ``dark``: chart axes and text are optimized for presentation against a
159
+ dark or black background.
160
+
161
+ Choosing a ``theme`` value only updates the iframe snippet you use to
162
+ embed the chart in your application. The chart is not saved with a ``theme`` value. The chart renders with the light theme by default.
163
+ Embedded charts that do not include the theme parameter also render with
164
+ the light theme.
165
+
166
+ .. note::
167
+ Choosing the ``light`` or ``dark`` theme does not change the color
168
+ palette that chart data elements use. All bars and marks display
169
+ using the default palette or the custom palette the chart author
170
+ chose.
171
+
172
+ For example, if you choose a chart bar to render in black, choosing
173
+ the ``dark`` theme does not change the color of this bar to make it
174
+ more visible against a dark background.
175
+
176
+ Customization
177
+ ~~~~~~~~~~~~~
178
+
179
+ |charts| adds inline style properties to the iframe snippet you copy
180
+ from the UI that add a background color and a border with a box shadow
181
+ to the embedded chart based on the theme you selected:
182
+
183
+ - ``light`` theme ``background``: ``#FFFFFF``
184
+ - ``dark`` theme ``background``: ``#21313C``
185
+ - ``border``: ``none``
186
+ - ``border-radius``: ``2px``
187
+ - ``box-shadow``: ``0 2px 10px 0 rgba(70, 76, 79, .2)``
188
+ - ``width``: ``640``
189
+ - ``height``: ``480``
190
+
191
+ Change the values of the inline style properties to change how the
192
+ embedded chart displays in your application:
193
+
194
+ - Change the value of the ``background`` property to any value
195
+ supported by the ``background`` CSS property to display the chart
196
+ against it. See `background
197
+ <https://developer.mozilla.org/en-US/docs/Web/CSS/background>`__
198
+ in the MDN Web Docs for more information.
199
+
200
+ - Remove the ``background`` property to display the chart with a
201
+ transparent background, allowing your application's background to
202
+ display through the chart.
203
+
204
+ - Modify or remove the following properties to customize or remove the
205
+ chart border:
206
+
207
+ - ``border``
208
+ - ``border-radius``
209
+ - ``box-shadow``
210
+
211
+ - You can change the value of the ``theme`` query parameter in the
212
+ iframe snippet after you paste it into your application. If you do,
213
+ make sure you adjust the iframe's inline style properties to match the
214
+ theme you choose.
215
+
216
+ .. example::
217
+
218
+ If you change the ``theme`` from ``light`` to ``dark``, adjust the
219
+ value of the ``background`` property in the iframe snippet
220
+ to display the chart against a dark background.
221
+
222
+ Chart using ``light`` theme with default ``light`` theme
223
+ ``background`` of ``#FFFFFF``:
224
+
225
+ .. image:: /images/charts/light-theme-default.png
226
+
227
+ Chart using ``dark`` theme with default ``light`` theme
228
+ ``background`` of ``#FFFFFF``:
229
+
230
+ .. image:: /images/charts/dark-theme-light-theme-values.png
231
+
232
+ Chart using ``dark`` theme with default ``dark`` theme ``background``
233
+ of ``#21313C``:
234
+
235
+ .. image:: /images/charts/dark-theme-dark-theme-values.png
236
+
237
+ Example
238
+ ~~~~~~~
239
+
240
+ The following iframe embeds a chart with the ``dark`` theme with the
241
+ default ``dark`` theme inline style properties. The code is formatted
242
+ for readability.
243
+
244
+ .. code-block:: html
245
+ :copyable: false
246
+ :emphasize-lines: 2,3,7
247
+
248
+ <iframe style="
249
+ background: #21313C;border: none;border-radius: 2px;
250
+ box-shadow: 0 2px 10px 0 rgba(70, 76, 79, .2);"
251
+ width="640" height="480" src="
252
+ https://charts.mongodb.com/charts-crllr/embed/charts?id=a1b2c3d4-a1b2-c3d4-9766-47b0b2daaff3&
253
+ tenant=a1b2c3d4-a1b2-a1b2-a1b2-bb7f36c9def6&
254
+ theme=dark
255
+ "></iframe>
0 commit comments