第 5 章 · 第 1 节Chapter 5 · Section 1 基础Core
5.1 时间的属性Properties of time
识别顺序、连续、周期与层级结构对时间编码的影响。Explain how order, continuity, cycles and hierarchy influence temporal encoding.
本节要点Key points
- 时间有顺序、连续、周期、独立于空间和层级结构等属性。Time has properties including order, continuity, periodicity, independence from space and hierarchical structure.
- 不同属性适合不同编码:折线、日历、螺旋、故事线各有假设。Different properties suit different encodings: lines, calendars, spirals and storylines each make assumptions.
- 时间先后不等于因果关系,图形只能显示相关。Temporal order is not causation; a chart can show association only.
01理解概念Understand the concept
案例
原 6.1 节列出 5 个时间属性,没有可视化。这章把这 5 个属性变成可交互卡片。
概念与方法
- 有序性:时间是有序的,两个事件有先后次序,与因果关系紧密相连。
- 连续性:时间连续,两个时间点之间总存在另一个时间点。
- 周期性:自然过程常有循环规律(季节、昼夜),可采用循环时间域。
- 独立于空间:时间与空间紧相关,但科学过程大多独立处理。
- 结构性:时间尺度分年/月/日/时/分/秒,分割既有自然反映(昼夜)也有人为定义(60 秒)。
为什么 5 个属性都重要?
设计时序图前先想清楚这 5 个属性,能避免常见错误:
- 有序性缺失 → 散点图错位成噪声
- 连续性混淆 → 离散数据用错连线
- 周期性忽略 → 季节趋势被"抹平"
- 结构性不匹配 → 工作日/周末、闰年都出错
Case study
Section 6.1 lists the 5 time properties; this chapter turns them into interactive examples. This chapter turns those 5 properties into interactive cards.
Embedding Chen Wei's Textbook Theory
- Order: Time is ordered—any two events have a before/after, tightly linked to causality.
- Continuity: Time is continuous—between any two moments there is always another moment.
- Periodicity: Natural processes often follow cyclic patterns (seasons, day/night)—a cyclic time domain can be used.
- Independence from space: Time is tightly coupled with space, but scientific processes usually treat them independently.
- Structure: Time scales split into year / month / day / hour / minute / second—some divisions reflect nature (day/night), others are human convention (60 seconds).
Why do all 5 properties matter?
Thinking through these 5 properties before designing a time series chart avoids common pitfalls:
- Missing order → scatter plot misaligned into noise
- Confused continuity → discrete data wrongly connected
- Ignored periodicity → seasonal trends “flattened out”
- Mismatched structure → weekdays/weekends, leap years all go wrong
02动手实验Try the experiment
试一试:Try this: 逐项查看时间属性,为每项找一个适合的图表例子,区分观测先后与因果关系。Explore each property and propose a chart example. Distinguish temporal order from causation.
实验将在进入此区域时加载,需要启用 JavaScript。The experiment loads when you reach this area. JavaScript is required.
此处数据用于教学演示,不据此作真实人口、气候或电影时间点推断。These data illustrate visualization methods, not factual population, climate or movie-timing claims. Some experiment controls use Chinese labels.
做完后:你应该看到After the experiment: what to look for
03代码与讲解Code and explanation收起 / 展开Collapse / expand +
⭐ 关键代码
⭐ 关键点 1:5 个属性以对象数组组织
// 单一数据源:5 个属性 + 含义 + 例子 + 颜色
const TIME_ATTRIBUTES = [
{ key: 'ordered', name: '有序性', icon: '↗',
desc: '时间是有序的。两个事件发生的时间有先后次序,与因果关系紧密相连。',
example: '火车时刻表、事件日志、git commit history', color: '#3b82f6' },
{ key: 'continuous', name: '连续性', icon: '∞',
desc: '时间是连续的。两个时间点之间总存在另一个时间点。',
example: '实时传感器数据(温度、心率)、流式数据流', color: '#10b981' },
{ key: 'periodic', name: '周期性', icon: '🔁',
desc: '许多自然过程有循环规律(季节、昼夜)。可采用循环时间域表示。',
example: '24h 体温、12 个月气温、年周期销售', color: '#f59e0b' },
{ key: 'spatial_independent', name: '独立于空间', icon: '✂️',
desc: '时间与空间紧相关,但科学过程大多将它们独立处理。',
example: '折线图 x 轴只用时间、y 轴只用度量', color: '#8b5cf6' },
{ key: 'structured', name: '结构性', icon: '📐',
desc: '时间尺度分年/月/日/时/分/秒,分割既有自然反映(昼夜)也有人为定义。',
example: '日历/周排列、闰年调整、工作日 vs 周末', color: '#ec4899' }
];
⭐ 对象数组 = 一份数据 + 多处使用。卡片渲染、详细解释、筛选过滤都从同一数据源派生,避免改一处漏一处。
⭐ 关键点 2:d3.timeDay.range 生成等间距日序列
// 生成 2024-01-01 到 2024-12-31 之间所有日期(366 天)
const days = d3.timeDay.range(new Date(2024, 0, 1), new Date(2025, 0, 1));
// 输出:[Date(2024-01-01), Date(2024-01-02), ..., Date(2024-12-31)]
console.log(days.length); // 366(闰年)
⭐ d3.timeDay 是 d3-time 模块的核心:range(start, stop) 返回两个时刻之间所有"日"的离散数组,offset(date, n) 加减 n 天。结构性(structural)就靠这种"时间尺度"操作实现。
⭐ Key Code
⭐ Key Point 1: the 5 properties are organized as an array of objects
const TIME_ATTRIBUTES = [
{ key: 'ordered', name: '有序性', icon: '↗',
desc: '时间是有序的。两个事件发生的时间有先后次序,与因果关系紧密相连。',
example: '火车时刻表、事件日志、git commit history', color: '#3b82f6' },
{ key: 'continuous', name: '连续性', icon: '∞',
desc: '时间是连续的。两个时间点之间总存在另一个时间点。',
example: '实时传感器数据(温度、心率)、流式数据流', color: '#10b981' },
{ key: 'periodic', name: '周期性', icon: '🔁',
desc: '许多自然过程有循环规律(季节、昼夜)。可采用循环时间域表示。',
example: '24h 体温、12 个月气温、年周期销售', color: '#f59e0b' },
{ key: 'spatial_independent', name: '独立于空间', icon: '✂️',
desc: '时间与空间紧相关,但科学过程大多将它们独立处理。',
example: '折线图 x 轴只用时间、y 轴只用度量', color: '#8b5cf6' },
{ key: 'structured', name: '结构性', icon: '📐',
desc: '时间尺度分年/月/日/时/分/秒,分割既有自然反映(昼夜)也有人为定义。',
example: '日历/周排列、闰年调整、工作日 vs 周末', color: '#ec4899' }
];
⭐ Array of objects = one data source, many uses. Card rendering, detailed explanations, and filtering all derive from the same source—so you never miss a spot when editing.
⭐ Key Point 2: d3.timeDay.range generates an equally-spaced day sequence
const days = d3.timeDay.range(new Date(2024, 0, 1), new Date(2025, 0, 1));
console.log(days.length);
⭐ d3.timeDay is the core of the d3-time module: range(start, stop) returns a discrete array of every “day” between two moments; offset(date, n) adds or subtracts n days. Structure (structural) is achieved through this kind of “time-scale” operation.
04练习Quiz
学完后,可以标记进度。Mark this section when you finish.