# 对数轴

¥Logarithmic Axis

对数刻度用于绘制数值数据图表。它可以放在 x 轴或 y 轴上。顾名思义,对数插值用于确定值在轴上的位置。

¥The logarithmic scale is used to chart numerical data. It can be placed on either the x or y-axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis.

# 配置选项

¥Configuration Options

# 所有笛卡尔轴的通用选项

¥Common options to all cartesian axes

命名空间:options.scales[scaleId]

¥Namespace: options.scales[scaleId]

名称 类型 默认 描述
bounds string 'ticks' 确定比例界限。更多...
clip boolean true 如果为 true,则根据比例尺而不是图表区域的大小来裁剪数据集绘图
position string | object 轴的位置。更多...
stack string 堆栈组。相同 position 和相同 stack 的轴堆叠。
stackWeight number 1 堆栈组中秤的重量。用于确定组内比例分配的空间量。
axis string 这是哪种类型的轴。可能的值是:'x','y'。如果未设置,则从应为 'x' 或 'y' 的 ID 的第一个字符推断。
offset boolean false 如果为 true,则会在两个边缘添加额外的空间,并且轴会缩放以适合图表区域。对于柱状图,默认设置为 true。
title object 缩放标题配置。更多...

# 所有轴的通用选项

¥Common options to all axes

命名空间:options.scales[scaleId]

¥Namespace: options.scales[scaleId]

名称 类型 默认 描述
type string 使用的规模类型。可以使用字符串键创建和注册自定义比例。这允许更改图表的轴类型。
alignToPixels boolean false 将像素值与设备像素对齐。
backgroundColor Color 比例区域的背景颜色。
border object 边框配置。更多...
display boolean|string true 控制坐标轴全局可见性(true 时可见,false 时隐藏)。当 display: 'auto' 时,仅当至少一个关联数据集可见时,轴才可见。
grid object 网格线配置。更多...
min number 用户定义的最小比例数,覆盖数据中的最小值。更多...
max number 用户定义的最大比例数,覆盖数据中的最大值。更多...
reverse boolean false 反转比例。
stacked boolean|string false 数据是否应该堆叠。更多...
suggestedMax number 计算最大数据值时使用的调整。更多...
suggestedMin number 计算最小数据值时使用的调整。更多...
ticks object 勾选配置。更多...
weight number 0 用于对轴进行排序的权重。权重越高,离图表区域越远。

# 刻度配置

¥Tick Configuration

# 对数轴特定选项

¥Logarithmic Axis specific options

命名空间:options.scales[scaleId].ticks

¥Namespace: options.scales[scaleId].ticks

名称 类型 默认 描述
format object 默认标签格式化程序使用的 Intl.NumberFormat (opens new window) 选项

# 所有笛卡尔轴的通用刻度选项

¥Common tick options to all cartesian axes

命名空间:options.scales[scaleId].ticks

¥Namespace: options.scales[scaleId].ticks

名称 类型 默认 描述
align string 'center' 沿轴的刻度对齐。可以是 'start'、'center'、'end' 或 'inner'。inner alignment 表示水平轴的第一个刻度对齐 start,最后一个刻度对齐 end
crossAlign string 'near' 垂直于轴的刻度对齐。可以是 'near'、'center' 或 'far'。见 刻度对齐
sampleSize number ticks.length 决定适合多少标签时要检查的刻度数。设置较小的值会更快,但当标签长度变化很大时可能不太准确。
autoSkip boolean true 如果为真,则自动计算可以显示多少标签并相应地隐藏标签。在跳过任何标签之前,标签将旋转到 maxRotation。无论如何关闭 autoSkip 以显示所有标签。
autoSkipPadding number 3 启用 autoSkip 时在水平轴上的刻度之间填充。
includeBounds boolean true 定义的 min 和 max 值是否应显示为刻度,即使它们不是 "nice"。
labelOffset number 0 从刻度中心点偏移标签的距离(以像素为单位)(x 轴在 x 方向,y 轴在 y 方向)。注意:这可能会导致边缘的标签被画布边缘裁剪
maxRotation number 50 旋转以压缩标签时刻度标签的最大旋转。注意:除非必要,否则不会发生轮换。注意:仅适用于水平刻度。
minRotation number 0 刻度标签的最小旋转。注意:仅适用于水平刻度。
mirror boolean false 围绕轴翻转刻度标签,在图表内部而不是外部显示标签。注意:仅适用于垂直刻度。
padding number 0 刻度标签和轴之间的填充。当设置在垂直轴上时,这适用于水平 (X) 方向。当设置在水平轴上时,这适用于垂直 (Y) 方向。
maxTicksLimit number 11 要显示的最大刻度线和网格线数。

# 所有轴的通用刻度选项

¥Common tick options to all axes

命名空间:options.scales[scaleId].ticks

¥Namespace: options.scales[scaleId].ticks

名称 类型 可编写脚本 默认 描述
backdropColor Color 是的 'rgba(255, 255, 255, 0.75)' 标签背景的颜色。
backdropPadding Padding 2 标签背景的填充。
callback function 返回应显示在图表上的刻度值的字符串表示形式。见 callback。
display boolean true 如果为真,则显示刻度标签。
color Color 是的 Chart.defaults.color 刻度的颜色。
font Font 是的 Chart.defaults.font 见 字体
major object {} 主要刻度配置。
padding number 3 设置刻度标签相对于轴的偏移量
showLabelBackdrop boolean 是的 true 用于径向刻度,false 否则 如果为真,则在刻度标签后面绘制背景。
textStrokeColor Color 是的 `` 文本周围笔划的颜色。
textStrokeWidth number 是的 0 文本周围的笔画宽度。
z number 0 刻度层的 z-index。在图表区域绘制刻度时很有用。值 <= 0 绘制在数据集下方, > 0 绘制在顶部。

# 内部数据格式

¥Internal data format

在内部,对数刻度使用数字数据。

¥Internally, the logarithmic scale uses numeric data.