4.5.6 Visualize Data in a Line Chart

A line chart is a graphical representation used to display data points connected by straight lines.

When to use this chart: Use this chart to visualize trends, changes, and relationships in data over a continuous period.
Dataset: SH.SALES table in the SH schema.
To visualize data in a line chart:
  1. Enter the text of the first step here.
    %sql
    select * from SH.SALES
  2. By default, the dataset is displayed in a table. Click on the line chart icon.

    Figure 4-29 Sales Table with the Line Chart icon highlighted


    Sales Table with the Line Chart icon highlighted

  3. By default, the line chart shows the average amount sold from the year 1998 till 2001, as shown in the screenshot below.

    Figure 4-30 Line Chart - Depicting the average of amount sold from 1998 - 2001


    Line Chart

    Click on the Settings icon to view the attributes that are plotted along the X and Y axis. The dates on which the product was sold from the year 1998 till 2001 are plotted along the X-axis. Corresponding to each sale date, the average of the amount sold is plotted along the Y-axis.
  4. Click on the Settings icon. Under Setup, edit the following:
    • Aggregate Duplicate: Decides what should happen with values that are within the same group. Select Sum. This will show the sum of the amount sold for the product with PROD_ID 13, from 1998 to 2001.
    • Series to Show: All fields in the result-set that are of type number can be selected. Selecting multiple fields will add additional diagrams to the visualization. Select AMOUNT SOLD.
    • Group By: All fields in the result-set can be selected. The more groups exist, the more the dataset shrinks since it collects all fields and concatenates same values. Select TIME_ID.
  5. Click Customization and edit the following:
    • X-axis: Enter Time: 1998 - 2001. The dates on which the product was sold from the year 1998 till 2001 are plotted along the X-axis.
    • Y-axis: Enter Amount Sold. Corresponding to each sale date, the sum of the amount sold is plotted along the Y-axis.
    • Description: Enter Sales trend of product ABC
    The line chart now displays the sum of the amount sold from the year 1998 to 2001, as shown below. Hover your cursor over the highest point in the line chart to view the values. You can see that on 5/30/2000, the product recorded the highest sale in terms of the sum of the amount sold.

    Figure 4-31 Line chart Line chart - Depicting the sum of amount sold from 1998 - 2001


    Line chart - Depicting the sum of amount sold from 1998 - 2001

This completes the task of visualizing your data in a line chart.