Skip to content

Commit e8b0be1

Browse files
(DOCSP-10974): Refactor Build Charts ToC (#371)
* (DOCSP-10974): Refactor Build Charts ToC * Updates per reviews * title tweak
1 parent 680e79c commit e8b0be1

12 files changed

+234
-136
lines changed

config/redirects

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ symlink: saas -> master
66
symlink: current -> 19.12
77
symlink: onprem -> 19.12
88
raw: charts/index.html -> ${base}/saas
9-
raw: charts/ -> ${base}/saas
9+
raw: charts/master/sort-limit-data/ -> ${base}/saas/bin-data
1010
raw: charts/master/administration/ -> ${base}/master
1111
raw: charts/master/administration/backup-and-restore-keys/ -> ${base}/master
1212
raw: charts/master/administration/configure-https-deployment/ -> ${base}/master
@@ -15,6 +15,7 @@ raw: charts/master/administration/start-stop-charts/ -> ${base}/master
1515
raw: charts/master/installation/ -> ${base}/master/launch-charts
1616
raw: charts/master/user-management/ -> ${base}/master
1717
raw: charts/master/filter-documents -> ${base}/master/filter-chart-results
18+
raw: charts/master/
1819
[19.09-19.12]: charts/${version}/pricing -> ${base}/${version}
1920
[19.09-19.12]: charts/${version}/launch-charts -> ${base}/${version}/installation
2021
[19.09-19.12]: charts/${version}/chart-type-reference/circular-charts -> ${base}/${version}/chart-type-reference/donut-chart

source/aggregation-pipeline-generation.txt

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
.. _aggregation-pipeline-generation:
22

3-
===========================
4-
Charts Aggregation Pipeline
5-
===========================
3+
============================
4+
Backing Aggregation Pipeline
5+
============================
66

77
.. default-domain:: mongodb
88

9-
In order to get the data needed to render a chart, |charts-short| creates a MongoDB Aggregation Pipeline which is executed on the
10-
MongoDB database server. The pipeline consists of multiple stages, each of which is generated based on different settings specified
11-
by the chart's author. This document explains how the various Chart Builder settings are used to construct the Aggregation Pipeline.
12-
You can view the pipeline used to create a chart by choosing the :guilabel:`View Aggregation Pipeline` option in the Chart Builder's
13-
ellipsis dropdown on the top right.
9+
To get the data needed to render a chart, |charts-short| creates a
10+
MongoDB Aggregation Pipeline which is executed on the MongoDB database
11+
server. The pipeline consists of multiple stages, each of which is
12+
generated based on different settings specified by the chart's author.
13+
This document explains how the various Chart Builder settings are used
14+
to construct the Aggregation Pipeline. You can view the pipeline used to
15+
create a chart by choosing the :guilabel:`View Aggregation Pipeline`
16+
option in the Chart Builder's ellipsis dropdown on the top right.
1417

1518

1619
The pipeline constructed by |charts| consists of the following segments in the following order:
@@ -25,23 +28,27 @@ The pipeline constructed by |charts| consists of the following segments in the f
2528
#. Maximum Document limit
2629

2730
.. note::
28-
You do not need to configure all of the above settings when creating a chart. Unspecified settings are skipped when
29-
generating the aggregation pipeline.
31+
You do not need to configure all of the above settings when creating
32+
a chart. Unspecified settings are skipped when generating the
33+
aggregation pipeline.
3034

3135

3236
.. note::
33-
Sorts and limits specified in the encoding panel are currently not included in the aggregation pipeline. Instead, the sorting and limiting is
34-
applied on the client-side while rendering the chart.
37+
Sorts and limits specified in the encoding panel are currently not
38+
included in the aggregation pipeline. Instead, the sorting and
39+
limiting is applied on the client-side while rendering the chart.
3540

3641

3742
Example
3843
-------
3944

40-
The following chart shows the total sale amounts from an office supply company, categorized by
41-
purchase method. Each document in the data collection represents a single sale.
45+
The following chart shows the total sale amounts from an office supply
46+
company, categorized by purchase method. Each document in the data
47+
collection represents a single sale.
4248

43-
Using this chart as an example, we will explore how the specifications for each of the above settings change the
44-
aggregation pipeline generated by |charts|.
49+
Using this chart as an example, we will explore how the specifications
50+
for each of the above settings change the aggregation pipeline generated
51+
by |charts|.
4552

4653
.. figure:: /images/charts/agg-pipeline.png
4754
:figwidth: 720px
@@ -51,15 +58,15 @@ aggregation pipeline generated by |charts|.
5158
Encoding
5259
~~~~~~~~
5360

54-
Without any :guilabel:`Data Source` pipeline, :guilabel:`Query` bar queries,
55-
calculated fields, and filters added in the :guilabel:`Filter` pane, |charts| generates the
56-
following aggregation pipeline:
61+
Without any :guilabel:`Data Source` pipeline, :guilabel:`Query` bar
62+
queries, calculated fields, and filters added in the :guilabel:`Filter`
63+
pane, |charts| generates the following aggregation pipeline:
5764

5865
.. code-block:: javascript
5966
:emphasize-lines: 1-31
6067

6168
{
62-
"$addFields": { //Encoding
69+
"$addFields": { //Encoding
6370
"__alias_0": {
6471
"$sum": "$items.price"
6572
}
@@ -94,8 +101,9 @@ following aggregation pipeline:
94101
}
95102

96103

97-
The pipeline at this stage only consists of groups from the :guilabel:`Encode` panel and the maximum
98-
document limit, which is set to 5000 by |charts|.
104+
The pipeline at this stage only consists of groups from the
105+
:guilabel:`Encode` panel and the maximum document limit, which is set to
106+
5000 by |charts|.
99107

100108
Adding Queries
101109
~~~~~~~~~~~~~~
@@ -121,7 +129,8 @@ Query:
121129
}
122130

123131

124-
Applying the above query in the :guilabel:`Query` bar generates the following chart and aggregation pipeline:
132+
Applying the above query in the :guilabel:`Query` bar generates the
133+
following chart and aggregation pipeline:
125134

126135
.. figure:: /images/charts/agg-pipeline-query.png
127136
:figwidth: 720px
@@ -133,7 +142,7 @@ Aggregation Pipeline:
133142
:emphasize-lines: 1-18
134143

135144
{
136-
"$match": { //Query
145+
"$match": { // Query
137146
"$and": [
138147
{
139148
"saleDate": {
@@ -185,16 +194,18 @@ Aggregation Pipeline:
185194
}
186195

187196

188-
The aggregation pipeline now starts with the query applied, and is followed by the groups selected in the
189-
:guilabel:`Encode` panel and the max document limit.
197+
The aggregation pipeline now starts with the query applied, and is
198+
followed by the groups selected in the :guilabel:`Encode` panel and the
199+
max document limit.
190200

191201

192202
Adding Calculated Fields
193203
~~~~~~~~~~~~~~~~~~~~~~~~
194204

195-
We can also change the chart to show the total revenue generated categorized by
196-
purchase method. To accomplish this task, we will create a calculated field that calculates
197-
the total revenue by multiplying price by quantity. Adding this new calculated field, in addition to the
205+
We can also change the chart to show the total revenue generated
206+
categorized by purchase method. To accomplish this task, we will create
207+
a calculated field that calculates the total revenue by multiplying
208+
price by quantity. Adding this new calculated field, in addition to the
198209
query above, produces the following chart and pipeline:
199210

200211

@@ -230,7 +241,7 @@ Aggregation Pipeline:
230241
}
231242
},
232243
{
233-
"$addFields": { //Calculated Field
244+
"$addFields": { // Calculated Field
234245
"revenue": {
235246
"$reduce": {
236247
"input": "$items",
@@ -279,15 +290,18 @@ Aggregation Pipeline:
279290
}
280291

281292

282-
The updated pipeline now includes the calculated field right below the query applied in the :guilabel:`Query` bar while the order of
283-
the rest of the components remains unchanged.
293+
The updated pipeline now includes the calculated field right below the
294+
query applied in the :guilabel:`Query` bar while the order of the rest
295+
of the components remains unchanged.
284296

285297

286298
Adding Filters
287299
~~~~~~~~~~~~~~
288300

289-
This chart can be further refined by adding a filter in the :guilabel:`Filter` pane to only select in-store sales made in the New York location.
290-
Adding this filter produces the following chart and aggregation pipeline:
301+
This chart can be further refined by adding a filter in the
302+
:guilabel:`Filter` pane to only select in-store sales made in the New
303+
York location. Adding this filter produces the following chart and
304+
aggregation pipeline:
291305

292306
.. figure:: /images/charts/agg-pipeline-with-filter.png
293307
:figwidth: 720px
@@ -339,7 +353,7 @@ Aggregation Pipeline:
339353
}
340354
},
341355
{
342-
"$match": { // Filter
356+
"$match": { // Filter
343357
"storeLocation": {
344358
"$nin": [
345359
null,
@@ -394,5 +408,6 @@ Aggregation Pipeline:
394408
"$limit": 5000
395409
}
396410

397-
The pipeline now includes the storeLocation filter right below the calculated field while the order of
398-
the rest of the components remains unchanged.
411+
The pipeline now includes the ``storeLocation`` filter right below the
412+
calculated field while the order of the rest of the components remains
413+
unchanged.

source/aggregation-pipeline.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Run Aggregation Pipelines on Your Data
66

77
.. default-domain:: mongodb
88

9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
915
:manual:`Aggregation pipelines </core/aggregation-pipeline/>` transform
1016
your documents into an aggregated set of results. In |charts|,
1117
aggregation pipelines are commonly used to visualize new fields created

source/bin-data.txt

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
.. _charts-bin-data:
2-
3-
========
4-
Bin Data
5-
========
1+
==============================
2+
Bin, Sort, and Limit Your Data
3+
==============================
64

75
.. default-domain:: mongodb
86

7+
You can bin, sort, and limit data in your charts to highlight key
8+
aspects in your data.
9+
910
.. contents:: On this page
1011
:local:
1112
:backlinks: none
1213
:depth: 1
1314
:class: singlecol
1415

16+
.. _charts-bin-data:
17+
18+
Bin Data
19+
--------
20+
1521
|charts| supports *binning* both numeric and date fields in your
1622
data. Binning breaks continuous data into discrete groups called
1723
*bins*, with each bin containing a contiguous subset of the original
@@ -35,7 +41,7 @@ date.
3541
.. _bin-date-fields:
3642

3743
Bin Date Fields
38-
---------------
44+
~~~~~~~~~~~~~~~
3945

4046
When handling dates, this data often comes in a continuous
4147
form. It can be useful to split this data into a specific windows of
@@ -120,7 +126,7 @@ visualization with no grouping performed.
120126
:alt: Charts binning by day example
121127

122128
Bin Numeric Fields
123-
------------------
129+
~~~~~~~~~~~~~~~~~~
124130

125131
|charts| can also bin numeric fields from a continuous set into groups
126132
of a specified size. This
@@ -160,7 +166,7 @@ to the visualization, rather than being grouped into bins.
160166
:alt: Charts numeric binning example
161167

162168
Empty Bins
163-
----------
169+
~~~~~~~~~~
164170

165171
When binning is enabled, |charts-short| displays entries for
166172
empty bins within the minimum and maximum data range a chart displays.
@@ -205,3 +211,53 @@ chart type:
205211
- Linear interpolation, with no data marker on the ``null`` bins.
206212
|charts-short| doesn't display data labels for ``null`` bins,
207213
even if enabled.
214+
215+
.. _charts-sort-data:
216+
217+
Sort Data
218+
---------
219+
220+
By default, |charts-short| sorts data based on the :guilabel:`Value`
221+
field in descending order.
222+
223+
Use the :guilabel:`Sort By` dropdown in the Chart Builder to sort by
224+
either the :guilabel:`Category` field or aggregated value.
225+
226+
To toggle between ascending or descending sort order, click the ``a-z``
227+
button to the right of the :guilabel:`Sort By` dropdown.
228+
229+
.. _charts-limit-data:
230+
231+
Limit Data
232+
----------
233+
234+
You can apply a limit to the :guilabel:`Category` encoding channel
235+
to only include a specified number of categories in your visualization.
236+
The categories included are the *first* matching categories based on
237+
the :ref:`sort order <charts-sort-data>` specified. Limiting data can
238+
be useful when visualizing data with so many categories it becomes
239+
difficult to create a meaningful chart.
240+
241+
.. example::
242+
243+
The following chart shows the average
244+
`IMDb <https://www.imdb.com/>`_ rating of movies from a
245+
particular country:
246+
247+
.. figure:: /images/charts/charts-movie-ratings-by-country.png
248+
:figwidth: 720px
249+
:alt: Movie ratings by country
250+
251+
The dataset contains movies from many different countries, but it
252+
would be most interesting to see which countries produce the
253+
highest-rated movies. We can accomplish this by applying a limit to
254+
only show countries with the 10 highest average ratings for movies.
255+
256+
Switch the :guilabel:`Limit Results` toggle to ``On`` and leave the
257+
:guilabel:`Show` input at the default value of 10. The chart is now
258+
much easier to understand, and we have a clear view of the countries
259+
with the highest-rated movies:
260+
261+
.. figure:: /images/charts/charts-movie-ratings-by-country-limited.png
262+
:figwidth: 720px
263+
:alt: Movie ratings by country limited

source/build-charts-reference.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. _build-charts-reference:
2+
3+
========================
4+
Chart Building Reference
5+
========================
6+
7+
.. default-domain:: mongodb
8+
9+
:ref:`charts-sample-mode`
10+
Learn how |charts| samples data to improve rendering performance.
11+
12+
:ref:`aggregation-pipeline-generation`
13+
Learn how |charts| creates an aggregation pipeline based on your
14+
chart configuration to render data.
15+
16+
.. class:: hidden
17+
18+
.. toctree::
19+
:titlesonly:
20+
21+
/sample-mode
22+
/aggregation-pipeline-generation

0 commit comments

Comments
 (0)