@@ -256,20 +256,33 @@ start date.
256256 - A dataset on various artists throughout history that you want to
257257 group by artistic period (for example, Renaissance, Romantic, Modern).
258258
259+ - A dataset containing fine-grained version numbers (e.g. ``2.3.0``,
260+ ``2.3.1``, ``2.3.2-rc1``, ``2.4.0``) which you'd like to analyze
261+ in coarser-grained groups (e.g. ``2.3``, ``2.4``).
262+
259263 Create a Bin from String Values
260264 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261265
262- To create a bin from selected category strings:
263-
264266 1. Drag a string field to a :guilabel:`Category` encoding channel.
265267
266268 #. Toggle :guilabel:`Binning` for the field to :guilabel:`On`.
267269
268270 #. Click :guilabel:`Add Bin`.
269271
270- #. In the :guilabel:`Add Bin` window, give your bin a title and
271- select the categories to include in your bin.
272+ #. In the :guilabel:`Add Bin` window, give your bin a title.
273+
274+ At this point you can either create a bin from a list of category
275+ strings or define a regular expression to match string values.
276+ You can use the list of category strings if you want to choose the
277+ exact values for each bin. A regular expression is a better choice
278+ if you want to pattern-match a larger range of potential values.
279+
280+ To create a bin from selected category strings:
281+
282+ 1. Click the :guilabel:`Select` radio button.
272283
284+ #. Select the categories to include in your bin.
285+
273286 #. Click :guilabel:`Save`. The :guilabel:`Bins` window shows the
274287 bins you have created and how many categories belong to each
275288 bin.
@@ -284,6 +297,47 @@ start date.
284297 data and may not include every value that exists in the data.
285298 You can manually add additional values to the list.
286299
300+ To create a bin from a regular expression:
301+
302+ 1. Click the :guilabel:`Regex` radio button.
303+
304+ #. Enter a regular expression in the :guilabel:`Insert regex` text
305+ box.
306+
307+ #. Select any desired flags from the dropdown menu to the right of
308+ the text box. You can use any combination of the four available
309+ flags:
310+
311+ .. list-table::
312+ :header-rows: 1
313+ :widths: 20 80
314+
315+ * - Flag
316+ - Description
317+
318+ * - ``i``
319+ - Case insensitive search
320+
321+ * - ``m``
322+ - Multiline mode
323+
324+ * - ``x``
325+ - Extended mode
326+
327+ * - ``s``
328+ - Single line mode
329+
330+ #. A sample of matching documents appears. If there are no matching
331+ documents, you can still save the bin.
332+
333+ #. Click :guilabel:`Save`. The :guilabel:`Bins` window shows the
334+ bins you have created. Bins created from a regular expression
335+ are noted with a :guilabel:`.*` icon.
336+
337+ You can add another bin by clicking the :guilabel:`Add Bin` link,
338+ or close the :guilabel:`Bins` window by clicking the :guilabel:`X`
339+ in the upper right corner.
340+
287341 Edit and Remove Existing Bins
288342 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289343
@@ -301,8 +355,8 @@ start date.
301355
302356 To remove a bin, click the :guilabel:`Trash` icon.
303357
304- Example
305- ~~~~~~~
358+ Examples
359+ ~~~~~~~~
306360
307361 The following chart groups genres from the
308362 :ref:`Movies Sample Data <sample-data>` into broader bins:
@@ -327,17 +381,34 @@ start date.
327381 :figwidth: 700px
328382 :alt: Chart containing binned category data
329383
384+ The following chart looks through the ``description`` field of the
385+ ``sample_airbnb.listingsAndReviews`` collection for certain words
386+ and compares the mean prices. It uses bins to group documents based
387+ on whether the ``description`` field contains a string matching the
388+ pattern specified by the regular expression.
389+
390+ .. figure:: /images/charts/nominal-binning-regex.png
391+ :figwidth: 700px
392+ :alt: Chart containing binned description data
393+
330394 Behavior
331395 ~~~~~~~~
332396
333- - A single category cannot belong to multiple bins.
397+ - Values can only belong to only one category bin, but they can belong
398+ to any number of regex bins.
334399
335400 - Any values shown on the chart that have not been added to any
336401 bins are automatically added to a default bin called
337402 :guilabel:`Other Values`.
338403
339- - The order in which bins appear in the :guilabel:`Bins` window
340- does not have any effect on the chart.
404+ - The order in which bins appear in the :guilabel:`Bins` window is
405+ significant. Each value is rendered in the chart as part of the
406+ highest-ranked bin it appears in.
407+
408+ .. note::
409+
410+ You can reorder your bins by dragging and dropping them in the
411+ :guilabel:`Bins` window.
341412
342413.. _charts-sort-data:
343414
@@ -424,3 +495,4 @@ difficult to create a meaningful chart.
424495 .. figure:: /images/charts/charts-movie-ratings-by-country-limited.png
425496 :figwidth: 720px
426497 :alt: Movie ratings by country limited
498+
0 commit comments