This topic describes how to configure a horizontal bar chart to display query results. It also includes examples.

Background information

A bar chart is a horizontal column chart. It is used to analyze the top N values of fields. It is configured in a way similar to a column chart.

The basic elements of a bar chart are as follows:
  • X-axis (vertical)
  • Y-axis (horizontal)
  • Rectangular bar
  • Legend

Each rectangular bar has a fixed height and a varying width that indicates a value. You can use a grouped bar chart to display the data if multiple columns of data are configured for the Y-axis.

Procedure

  1. On the Search & Analysis page of a Logstore, enter a search and analytics statement in the search box, specify the time range, and then click Search & Analyze.
    The Chart tab is automatically displayed when a query is completed.
  2. Click Bar chart - 001 to display the query results in a bar chart.
  3. On the Properties tab on the right, configure the properties of the bar chart.
    Note
    • Bar charts are suitable to display query results if the number of returned log entries is no greater than 20. You can use a LIMIT clause to control the number of categorical rectangular bars. Analysis results may not be clearly displayed if the chart contains excessive rectangular bars. You can use an ORDER BY clause to analyze the top N values of fields. In addition, we recommend that you configure no more than five fields for the Y-axis.
    • You can use a grouped bar chart to display query results. However, the values represented by each rectangular bar in a group must positively or negatively associated with each other.
    Configuration item Description
    X Axis The categorical data.
    Y Axis The numeric data. You can configure one or more fields for the Y-axis.
    Legend The position where the legend is located in the chart. Valid values: Top, Bottom, Left, and Right.
    Format X-axis The format in which data configured for the X-axis is displayed.
    Margin The distance of the axis to the borders of the chart, including Top Margin, Bottom Margin, Right Margin, and Left Margin.

Examples

To analyze the request_uri with the top 10 number of visits and display the analysis results in a bar chart, run the following statement:

* | select  request_uri, count(1) as count group by request_uri order by count desc limit 10
Examples