Elasticsearch 简明教程
Elasticsearch - Area and Bar Charts
面积图是折线图的扩展,其中折线图和坐标轴之间的面积会突出显示为某种颜色。条形图表示成一系列值的组织数据,然后沿坐标轴绘制。它可以由水平条或垂直条组成。
An area chart is an extension of line chart where the area between the line chart and the axes is highlighted with some colours. A bar chart represents data organized into a range of values and then plotted against the axes. It can consist of either horizontal bars or vertical bars.
在本章中,我们将看到使用 Kibana 创建的所有这三种类型的图形。正如前面章节中所讨论的,我们将继续使用电子商务索引中的数据。
In this chapter we will see all these three types of graphs that is created using Kibana. As discussed in earlier chapters we will continue to use the data in the ecommerce index.
Area Chart
在 Kibana 主屏幕中,我们找到了可视化名称选项,可视化名称选项使我们能够从 Elasticsearch 中存储的指标创建可视化和聚合。我们选择添加一个新的可视化,并选择下图所示的图像中的面积图选项。
In Kibana Home screen, we find the option name Visualize which allows us to create visualization and aggregations from the indices stored in Elasticsearch. We choose to add a new visualization and select Area Chart as the option shown in the image given below.

Choose the Metrics
下一个屏幕会提示我们选择用于创建面积图的指标。此处,我们选择总和作为聚合指标的类型。然后我们选择 total_quantity 字段作为要作为指标使用的字段。在 X 轴上,我们选择了 order_date 字段并以 5 的大小用给定的指标拆分序列。
The next screen prompts us for choosing the metrics which will be used in creating the Area Chart. Here we choose the sum as the type of aggregation metric. Then we choose total_quantity field as the field to be used as metric. On the X-axis, we chose the order_date field and split the series with the given metric in a size of 5.

运行上述配置之后,我们将得到如下所示的面积图作为输出 −
On running the above configuration, we get the following area chart as the output −

Horizontal Bar Chart
同样,对于水平条形图,我们从 Kibana 主屏幕选择新的可视化效果,然后选择水平条形图选项。然后,我们选择如下图所示的指标。在此处,我们选择求和作为名为产品数量的字段的聚合。然后,我们选择带有日期直方图的存储桶作为字段订单日期。
Similarly, for the Horizontal bar chart we choose new visualization from Kibana Home screen and choose the option for Horizontal Bar. Then we choose the metrics as shown in the image below. Here we choose Sum as the aggregation for the filed named product quantity. Then we choose buckets with date histogram for the field order date.

在运行上述配置时,我们可看到一个如下所示的水平条形图 −
On running the above configuration, we can see a horizontal bar chart as shown below −

Vertical Bar Chart
对于垂直条形图,我们从 Kibana 主屏幕选择新的可视化效果,然后选择垂直条形图选项。然后,我们选择如下图所示的指标。
For the vertical bar chart, we choose new visualization from Kibana Home screen and choose the option for Vertical Bar. Then we choose the metrics as shown in the image below.
在此处,我们选择求和作为名为产品数量的字段的聚合。然后,我们选择带有日期直方图的存储桶作为字段订单日期,间隔为每周。
Here we choose Sum as the aggregation for the field named product quantity. Then we choose buckets with date histogram for the field order date with a weekly interval.

在运行上述配置时,将生成如下图所示的图表 −
On running the above configuration, a chart will be generated as shown below −
