Skip to main content

DataClock

汇总

DataClock 类可创建数据时钟。 数据时钟可直观地将时态数据汇总到两个维度,以揭示随时间变化的季节性或周期性模式和趋势。

了解有关 ArcGIS Pro 中数据时钟的详细信息

讨论

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

语法

DataClock(dateField, {numberField}, {timeUnitsRingWedge}, {aggregation}, {nullPolicy}, {classificationMethod}, {classCount}, {title}, {description}, {dataSource}, {displaySize}, {theme})

名称 说明 数据类型

dateField

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

String

numberField

(可选)

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

String

timeUnitsRingWedge

(可选)

指定数据时钟图中支持的时间单位对。

  • YEARS_MONTHS—Display years on the ring axis and months on the wedge axis.

  • YEARS_WEEKS—Display years on the ring axis and weeks on the wedge axis.

  • YEARS_DAYS—Display years on the ring axis and days on the wedge axis.

  • WEEKS_DAYS—Display weeks on the ring axis and days on the wedge axis.

  • DAYS_HOURS—Display days on the ring axis and hours on the wedge axis.

String

aggregation

(可选)

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

  • COUNT—将识别记录的总数。

  • SUM—将计算所有值的总和。

  • MEAN—将计算所有值的平均值。

  • MEDIAN—将计算所有值的中值。

  • MIN—将识别最小值。

  • MAX—将识别最大值。

String

nullPolicy

(可选)

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

  • null—将像元显示为空值。

  • zero—将像元显示为零。

String

classificationMethod

(可选)

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

  • equalIntervals—将使用等间隔方法。

  • geometricalIntervals—将使用几何间隔方法。

  • naturalBreaks—将使用自然间断点方法。

  • quantiles—将使用分位数方法。

String

classCount

(可选)

用于分类方法中的类数。

Integer

title

(可选)

图表的标题。 标题文本显示在图表视图的顶部,并在 内容 窗格中用作图表的标注。

String

description

(可选)

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

String

dataSource

(可选)

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

  • 数据集的路径(包括本地数据集、UNC 路径和服务 URL)

  • Apache Arrow 表对象

  • LayerTable 对象

Object

displaySize

(可选)

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

List

theme

(可选)

指定将应用于图表的主题。

  • Light—The Light theme will be applied.

  • Medium—The Medium theme will be applied.

  • Dark—The Dark theme will be applied.

String

属性

名称 说明 数据类型

aggregation

(读取和写入)

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

  • COUNT—将识别记录的总数。

  • SUM—将计算所有值的总和。

  • MEAN—将计算所有值的平均值。

  • MEDIAN—将计算所有值的中值。

  • MIN—将识别最小值。

  • MAX—将识别最大值。

String

classCount

(读取和写入)

用于分类方法中的类数。

Integer

classificationMethod

(读取和写入)

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

  • equalIntervals—将使用等间隔方法。

  • geometricalIntervals—将使用几何间隔方法。

  • naturalBreaks—将使用自然间断点方法。

  • quantiles—将使用分位数方法。

String

dataSource

(读取和写入)

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

  • 数据集的路径(包括本地数据集、UNC 路径和服务 URL)

  • Apache Arrow 表对象

  • LayerTable 对象

Object

dateField

(读取和写入)

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

String

description

(读取和写入)

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

String

displaySize

(读取和写入)

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

List

legend

(读取和写入)

图表图例的属性。

  • alignment - 指定图例的对齐。 对齐选项为 leftbottomtopright

  • title - 图例的标题。

  • visible - 指定是否在图表视图中显示图例。 True 显示图例, False 隐藏图例。

Object

nullPolicy

(读取和写入)

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

  • null—将像元显示为空值。

  • zero—将像元显示为零。

String

numberField

(读取和写入)

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

String

theme

(读取和写入)

指定将应用于图表的主题。

  • Light—将应用浅色主题。

  • Medium—将应用中等主题。

  • Dark—将应用深色主题。

String

timeUnitsRingWedge

(读取和写入)

指定数据时钟图中支持的时间单位对。

  • YEARS_MONTHS—在环轴上显示年份,在楔形轴上显示月份。

  • YEARS_WEEKS—在环轴上显示年份,在楔形轴上显示星期。

  • YEARS_DAYS—在环轴上显示年份,在楔形轴上显示日期。

  • WEEKS_DAYS—在环轴上显示星期,在楔形轴上显示日期。

  • DAYS_HOURS—在环轴上显示日期,在楔形轴上显示小时。

String

title

(读取和写入)

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

String

type

(只读)

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

String

方法

addToLayer(layer_or_layerfile)

addToLayer 方法可将图表对象添加到图层或表视图。

名称 说明 数据类型

layer_or_layerfile

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

Object

将图表添加到现有图层。

import arcpy

# Insert creation of chart object here
# ...

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)

exportToJPEG(path, width, height)

exportToJPEG 方法用于将图表导出为 JPEG 格式。

名称 说明 数据类型

path

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

String

width

The width of the output graphic.

Integer

height

The height of the output graphic.

Integer

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

import arcpy

# Insert creation of chart object here
# ...

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.exportToJPEG('theftsPerBeat.jpg', 800, 600)

exportToPNG(path, width, height)

exportToPNG 方法用于将图表导出为 PNG 格式。

名称 说明 数据类型

path

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

String

width

The width of the output graphic.

Integer

height

The height of the output graphic.

Integer

从图层访问现有图表,更新标题,然后将其导出为 .png 文件。

import arcpy

lyr = arcpy.mp.ArcGISProject('current').listLayers()[0]

# Retrieve the first chart belonging to the layer
chart = lyr.listCharts()[0]

# Update chart title
chart.title = 'Voter Turnout by State'

# Save the chart to PNG file with dimensions width=800, height=600
chart.exportToPNG('populationByState.png', 800, 600)

exportToSVG(path, width, height)

exportToSVG 方法可将图表导出为 SVG 格式。

名称 说明 数据类型

path

将图表以 SVG 格式导出时的路径。

String

width

输出图形的宽度。

Integer

height

输出图形的高度。

Integer

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

import arcpy

# Insert creation of chart object here
# ...

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

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

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

updateChart()

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

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

import arcpy

# Insert creation of chart object here
# ...

chart.addToLayer(myLayer)

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

代码示例

使用当前工程中的一个图层创建数据时钟图表,然后将该图表导出至 .svg 文件。

import arcpy
lyr = arcpy.mp.ArcGISProject("current").listMaps()[0].listLayers("car_accidents")[0]
chart = arcpy.charts.DataClock(dateField="Date", aggregation="count",
                               timeUnitsRingWedge="WEEKS_DAYS", dataSource=lyr)
chart.exportToSVG("data_clock.svg", width=750, height=500)