Exercise 2: Configuring Multi-Series Charts

COVE Data Definition Exercises

Learning Objective

This exercise, along with exercises 1 and 3, demonstrates how to configure bar and line charts from different source data formats.  With this exercise, you will also begin learning about some special charting options, as demonstrated in the example chart below.

(For explanations of the concepts demonstrated in this series of exercises, see Defining Data for Visualization.  For descriptions of the other exercises in this series, see the Exercise Index.

Source Data

This exercise uses the same data file you used in Exercise 1, but the bar chart you’re building is fundamentally differently from the chart you produced earlier.  See example chart below.

Screenshot of Excel file showing exercise source data

View source file [XLS – 191 B]

Visualization You’re Building

Follow the steps in this exercise to build the chart shown here. Note that the Male and Female categories for the date/category axis are structured vertically in the source file above.  This means that you must answer the data import questions differently than you did for Exercise 1 because the structure of the source data is different (even though the same file is used).

Note also the following:

  • The All values for Sex are not included in the chart.  This exercise demonstrates how to exclude categories from the date/category axis.
  • The legend is below the chart.
  • The bars are slightly rounded at the top.

Step-by-Step Instructions

Create the Content Item

  1. From the WCMS content (folder) browser, select New Content Item, and when prompted, select Data Visualization.
  2. Click the button Open Visualization Editor. 
  3. On the Choose Visualization Type tab, select Bar.

Import the Data

  1. In the Import Data tab, select Load from URL and then copy and paste the following URL:
    https://wwwdev.cdc.gov/wcms/4.0/cdc-wp/data-presentation/data/exercise-data/chart-hybrid-data-format.csv
  2. Click Load.
  3. Select Vertical for the Orientation.  (The chart you’re building has the sex categories on the date-category axis, and they are formatted vertically in the source file.)
  4. When asked whether there are multiple series, select Yes.
  5. When asked whether the series span multiple rows, select Single Row.  Keep in mind that, for charts, the series are the categories of data represented in the legend.  Each Sex category is contained within a single line in the source file.
  6. Click Configure your visualization.

Configure the Visualization

  1. In the General panel set the chart title, message, etc. as you like.
  2. In the Data Series panel select each age group.
  3. In the Left Value Axis panel enter “Total Cases” as the Label.
  4. Open the Date/Category Axis panel and select Sex as the Data Key. (Leave the Data Scaling Type as Categorical.)
  5. Click “Done” in the preview area and compare your new chart to the example in this document.  Note that your chart includes the “All” values from the Sex column on the date/category axis.  As for the value axis, it extends only to 6000, so you will need to change the maximum value.

Fine-Tune the Visualization

  1. In the Date/Category Axis panel check Exclude One or More Values and then select the All column for exclusion.
  2. In the Data Table panel enter an Index Column Header.  (Always ensure that your data tables have this text setting.)
  3. In the Left Value Axis panel, set the Size (Width) for better positioning of the label.  Also check Add Commas.  And set the Left Axis Max Value to 8000.
  4. In the Legend panel add a legend Title and change the Position to Bottom.
  5. If there is too much space between the chart and the legend, adjust the Size (Height) in the Date/Category Axis panel.
  6. If the legend text appears disproportionately large, you can set Font Size to Small in the Visual panel.
  7. Also in the Visual panel you can control the Bar Thickness.
  8. In the General panel, set the Bar Style to Rounded and the Rounding Style to Shallow.
  9. Don’t forget to save your visualization (with the extension .json).

General Tips

  • For most charts, there are three Data Scaling Type options for the Date/Category Axis:  one categorical option and two date options.  The charts you are building for Exercises 1 through 3 are categorical.  When you build a chart with dates along the date/category axis (which is typical of a line chart), you can use the option Exclude One or More Values to limit the date range.  Exercise 7 demonstrates date configuration.
  • You can find more information about date exclusion and other configuration settings in Common Configuration Settings for Maps and Charts.

Next Exercise

Continue to Exercise 3 to build a chart with the same source data but in a different format.