The line chart analyzes trends. It is typically used to indicate the changes of a group of data based on an ordered data type (successive time intervals in most cases) for analyzing the trend of data changes.

A line chart clearly shows the changes of data over a period in the following aspects:

  • Increment or decrement
  • Increment or decrement rate
  • Increment or decrement pattern, for example, periodic change
  • Peak value and valley value

Therefore, the line chart is the best choice for analyzing the trend of data changes over time. You can also use multiple lines to analyze the changing trend of multiple groups of data in the same period, and then analyze the mutual effect (such as increasing or decreasing at the same time and being inversely proportional to each other) among data in different groups.

Components

  • X-axis
  • Left Y-axis
  • (Optional) Right Y-axis
  • Data point
  • Line of changing trend
  • Legend

Procedure

  1. On the search page of a Logstore, enter a query and analysis statement in the search box, set the time range, and then click Search & Analysis.
  2. On the Graph tab, click to select the line chart.
  3. On the right-side Properties tab, configure the properties of the line chart.
    Note In a line chart, a single line must contain more than two data records to guarantee that the data trend can be analyzed. We also recommend that you configure no more than five lines in a line chart.

Properties

Configuration item Description
X Axis The data on the X-axis, which is usually a time sequence.
Left Y Axis The numeric data on the left Y-axis. You can map one or more columns of data to the Y-axis.
Right Y Axis The numeric data on the right Y-axis. You can map one or more columns of data to the Y-axis. The layer of the right Y-axis is higher than that of the left Y-axis.
Column Marker The column on the left Y-axis or right Y-axis that is selected as a histogram.
Legend The position where the legend is located in the chart. Valid values: Top, Bottom, Left, and Right.
RightFormat Left Y-axis The format in which data is displayed on the Y-axis.
Format Right Y-axis
Margin The distance of the axis to the borders of the chart, including Top Margin, Bottom Margin, Right Margin, and Left Margin.

Example

Simple line chart

To query the page views (PVs) of the IP address 10.0.192.0 within the last day, run the following statement:

remote_addr: 10.0.192.0 | select date_format(date_trunc('hour', __time__), '%m-%d %H:%i') 
as time, count(1) as PV group by time order by time limit 1000
Select time for X Axis, PV for Left Y Axis, and Bottom for Legend. Adjust the margins properly.
Figure 1. Simple line chart


Dual Y-axis line chart

To query the access PVs and unique visitors (UVs) within the last day, run the following statement:

* | select date_format(date_trunc('hour', __time__), '%m-%d %H:%i') as time, count(1) as PV, approx_distinct(remote_addr) as UV group by time order by time limit 1000

Select time for X Axis, PV for Left Y Axis, UV for Right Y Axis, and PV for Column Marker.

Figure 2. Dual Y-axis line chart