CalendarHeat

摘要

日历热点图通过将事件聚合到日历格网中显示时态数据中的模式。

了解有关 ArcGIS Pro 中的日历热点图的详细信息

说明

创建图表对象时,必须使用参数名指定类构造函数的可选参数;这些可选参数不能通过参数位置指定。 有关如何使用关键字指定参数的示例,请参阅代码示例部分。

语法

 CalendarHeat (dateField, {numberField}, {calendarType}, {viewType}, {includeLeapDay}, {aggregation}, {nullPolicy}, {classificationMethod}, {classCount}, {title}, {description}, {xTitle}, {yTitle}, {dataSource}, {displaySize})
参数说明数据类型
dateField

The name of the date field that is used to create the chart.

String
numberField

The name of the field that is aggregated and used to determine the color of the chart cells.

String
calendarType

Specifies the time-unit pair that is supported in the calendar heat chart.

  • YEAR_MONTHSDAYSDisplay months on the row axis and day of month on the column axis.
  • WEEK_DAYSHOURSDisplay days on the row axis and hour of day on the column axis.
String
viewType

Specifies whether the calendar will be collapsed into a single calendar view or displayed as sequential calendar views.

  • SINGLEDisplay as a single calendar view.
  • SEQUENTIALDisplay as sequential calendar views.
String
includeLeapDay

Specifies whether the leap day (February 29) cell will be included in the chart.

  • TrueInclude leap day.
  • FalseExclude leap day.
Boolean
aggregation

指定将应用于每个像元聚合值的统计计算方法。

  • COUNT将识别记录的总数。
  • SUM将计算所有值的总和。
  • MEAN将计算所有值的平均值。
  • MEDIAN将计算所有值的中值。
  • MIN将识别最小值。
  • MAX将识别最大值。
String
nullPolicy

指定返回空值的汇总像元的显示方式。

  • null将像元显示为空值。
  • zero将像元显示为零。
String
classificationMethod

指定用于可视化像元颜色和数据分类的分类方法。

  • equalIntervals将使用等间隔方法。
  • geometricalIntervals将使用几何间隔方法。
  • naturalBreaks将使用自然间断点方法。
  • quantiles将使用分位数方法。
String
classCount

The number of classes used in the classification method.

Integer
title

The title of the chart. The title text appears at the top of the chart view and is used as the label for the chart in the Contents pane.

String
description

The description of the chart. The description text appears at the bottom of the chart view.

String
xTitle

The title of the x-axis of the chart.

String
yTitle

The title of the y-axis of the chart.

String
dataSource

The data source of the chart. When a chart is exported using the exportToSVG method or displayed in an ArcGIS Notebook, the data source will be read and rendered on the chart. Valid data sources include the following:

  • Paths to datasets, including local datasets, UNC paths, and service URLs
  • Arrow table objects
  • Layer objects

Object
displaySize
[displaySize,...]

The size of the chart when exported using the exportToSVG method or displayed in an ArcGIS Notebook. The value must be specified as a two-item list in which the first item is the width of the chart and the second item is the height of the chart.

List

属性

属性说明数据类型
aggregation
(可读写)

指定将应用于每个像元聚合值的统计计算方法。

  • COUNT将识别记录的总数。
  • SUM将计算所有值的总和。
  • MEAN将计算所有值的平均值。
  • MEDIAN将计算所有值的中值。
  • MIN将识别最小值。
  • MAX将识别最大值。
String
calendarType
(可读写)

日历热点图中支持的时间单位对的描述。

  • YEAR_MONTHSDAYS在行轴上显示月份,在列轴上显示日期。
  • WEEK_DAYSHOURS在行轴上显示日期,在列轴上显示小时。
String
classCount
(可读写)

用于分类方法中的类数。

Integer
classificationMethod
(可读写)

指定用于可视化像元颜色和数据分类的分类方法。

  • equalIntervals将使用等间隔方法。
  • geometricalIntervals将使用几何间隔方法。
  • naturalBreaks将使用自然间断点方法。
  • quantiles将使用分位数方法。
String
dataSource
(可读写)

图表的数据源。 当通过 exportToSVG 方法导出图表或将其显示在 ArcGIS Notebook 中时,将读取数据源并将其呈现在图表上。 其中包括以下有效数据源:

  • 数据集的路径(包括本地数据集、UNC 路径和服务 URL)
  • Arrow 表对象
  • Layer 对象。

Object
dateField
(可读写)

用于创建图表的日期字段的名称。

String
description
(可读写)

图表的描述。 该描述文本会显示于图表视图底部。

String
displaySize
(可读写)

当使用 exportToSVG 方法导出图表或将其显示在 ArcGIS Notebook 中时,图表的大小。 该值必须指定为两个项目的列表,其中第一个项目是图表的宽度,第二个项目是图表的高度。

List
includeLeapDay
(可读写)

指定是否在图表中包含闰日(2 月 29 日)单元格。

  • True包含闰日。
  • False不包含闰日。
Boolean
legend
(可读写)

图表图例的属性。

  • visible - 指定是否在图表视图中显示图例。 True 显示图例,False 隐藏图例。
  • title - 图例的标题。
Object
nullPolicy
(可读写)

指定返回空值的汇总像元的显示方式。

  • null将像元显示为空值。
  • zero将像元显示为零。
String
numberField
(可读写)

聚合的字段的名称,用于确定图表单元格的颜色。

String
theme
(可读写)

指定应用于图表的主题的名称。

String
title
(可读写)

图表的标题。 标题文本显示于图表视图顶部,并用作内容窗格中按绘制顺序列出选项卡 按绘制顺序列出 的标注。

String
type
(只读)

用于指示图表类型的字符串值。

String
viewType
(可读写)

指定日历是显示为单个日历视图,还是显示为连续的日历视图。

  • SINGLE显示为单个日历视图显示。
  • SEQUENTIAL显示为连续的日历视图。
String
xAxis
(可读写)

x 轴的属性。

  • field - 用于创建图表的日期字段的名称。
  • logarithmic - CalendarHeat 类不支持此属性。
  • maximum - CalendarHeat 类不支持此属性。
  • minimum - CalendarHeat 类不支持此属性。
  • sort - CalendarHeat 类不支持此属性。
  • title - 图表中所显示的轴的标注。
Object
yAxis
(可读写)

y 轴的属性。

  • field - 聚合的字段的名称,用于确定图表单元格的颜色。
  • logarithmic - CalendarHeat 类不支持此属性。
  • maximum - CalendarHeat 类不支持此属性。
  • minimum - CalendarHeat 类不支持此属性。
  • sort - CalendarHeat 类不支持此属性。
  • title - 图表中所显示的轴的标注。
Object

方法概述

方法说明
addToLayer (layer_or_layerfile)

将图表对象添加到图层或独立表中。

exportToSVG (path, width, height)

将图表导出为 SVG 格式。

updateChart ()

更新图表属性可以同步对象与之前添加到图层的图表之间的更改。

方法

addToLayer (layer_or_layerfile)
参数说明数据类型
layer_or_layerfile

The chart will be added to the target object. The layer_or_layerfile argument can be a Layer or a Table object.

Object

定义图表属性后的最后一步通常是使用 addToLayer 方法将图表对象添加到图层或表中。

将图表添加到现有图层。

import arcpy

aprx = arcpy.mp.ArcGISProject("current")
map = aprx.listMaps()[0]
censusLayer = map.listLayers('Census Block Groups')[0]

# Add chart object to a layer
chart.addToLayer(censusLayer)
exportToSVG (path, width, height)
参数说明数据类型
path

The path where the chart will be exported in SVG format.

String
width

The width of the output graphic.

Integer
height

The height of the output graphic.

Integer

在某些情况下,您可能希望将图表另存为可在 ArcGIS Pro 外部共享和查看的图形。 导出为 SVG 图形格式是有好处的,因为图表元素和文本将存储为可在矢量图形软件中进行独立修改的矢量元素。 SVG 图形也可以调整为任何比例,而不会出现像素化或质量下降的情况。

将具有工程图层数据源的图表导出到 .svg 文件中。

import arcpy

aprx = arcpy.mp.ArcGISProject('current')
censusLayer = aprx.listMaps()[0].listLayers('Census Block Groups')[0]

# Set data source of chart object to a layer within current project
chart.dataSource = censusLayer

# Save the chart to file with dimensions width=500, height=500
chart.exportToSVG('populationByState.svg', 500, 500)

将具有要素服务数据源的图表导出到 .svg 文件中。


featureServiceURL = r'https://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/CrimesChiTheft/FeatureServer/0'

# Set data source of chart object to a feature service URL
chart.dataSource = featureServiceURL

# Save the chart to file with dimensions width=800, height=600
chart.exportToSVG('theftsPerBeat.svg', 800, 600)
updateChart ()

定义图表属性后的最后一步通常是使用 addToLayer 方法将图表对象添加到图层中。

要进一步修改图表属性,您可以修改原始图表的属性,而非从头开始创建新图表。 然后,您可以使用 updateChart 方法将所有更改同步到已添加到该图层的图表中。 由此可在图表属性窗格和图表视图中显示所做的更改。

可以使用 updateChart 方法将图表属性更改同步到图层中。


chart.addToLayer(myLayer)

# Further modification is necessary
chart.description = "Data from the U.S. Census Bureau"
chart.updateChart()

代码示例

可以创建一个日历热点图,然后将其添加至当前工程中的图层。


import arcpy
lyr = arcpy.mp.ArcGISProject("current").listMaps()[0].listLayers("car_accidents")[0]
chart = arcpy.charts.CalendarHeat(dateField="Date", calendarType="WEEK_DAYSHOURS", aggregation="count")
chart.addToLayer(lyr)