@@ -125,6 +125,57 @@ visualization with no grouping performed.
125
125
:figwidth: 680px
126
126
:alt: Charts binning by day example
127
127
128
+ Compare Periods
129
+ ~~~~~~~~~~~~~~~
130
+
131
+ When you use binned date data, you have the option to compare data across
132
+ periods of time. You can display cumulative totals or changes in value.
133
+
134
+ To use the compare periods feature, a chart must have:
135
+
136
+ - A :ref:`category channel <charts-channel-type-table>` with a :ref:`binned,
137
+ non-periodic date field <bin-date-fields>` encoded.
138
+ - An :ref:`aggregation <building-charts-aggregation>` channel.
139
+
140
+ If the conditions are met, the aggregation card has a toggle switch labeled
141
+ :guilabel:`Compare Periods`. When toggled on, a dropdown menu appears with
142
+ options for :guilabel:`Cumulative Total` and :guilabel:`Change in Value`.
143
+
144
+ On a :guilabel:`Cumulative Total` chart, each successive data point is
145
+ calculated by adding its own value added to the preceding chronological data
146
+ point. You can also specify a baseline value to serve as the initial value
147
+ of the cumulative total. The default baseline value is ``0``.
148
+
149
+ On a :guilabel:`Change in Value` chart, each successive data point shows the
150
+ difference between it and the preceding chronological data point. The first
151
+ data point in the chart will always be blank, because there is no previous
152
+ period to compare against.
153
+
154
+ The following types of charts can use the compare periods feature:
155
+
156
+ - :ref:`Bar and Column <column-bar-chart-ref>`
157
+ - :ref:`Discrete Line and Area <discrete-charts>`
158
+
159
+ .. note::
160
+
161
+ The cumulative data option is not available with :ref:`multi-series
162
+ charts <multi-series-charts>`.
163
+
164
+ .. example::
165
+
166
+ The following column chart visualizes yearly sales for an office supply
167
+ store as a cumulative total across five years. Each document in the
168
+ collection includes the date of the sale as ``salesDate`` and a ``quantity``
169
+ field with a count of items included in the sale.
170
+
171
+ The ``saleDate`` field is binned by year. The ``items`` field is an array
172
+ in which each item has a ``quantity`` field, which is added to the cumulative
173
+ total with a ``SUM`` aggregation operation.
174
+
175
+ .. figure:: /images/charts/cumulative-total.png
176
+ :figwidth: 680px
177
+ :alt: Charts cumulative total example
178
+
128
179
Bin Numeric Fields
129
180
~~~~~~~~~~~~~~~~~~
130
181
0 commit comments