traffic-diagram 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.trae/documents/Update README.md for Traffic Lane Component.md +37 -0
- package/.trae/documents/npm Publish Plan.md +27 -0
- package/.trae/documents/plan_20251222_071731.md +64 -0
- package/.trae/documents/plan_20251222_074833.md +23 -0
- package/.trae/documents/plan_20251222_081357.md +23 -0
- package/README.md +311 -0
- package/dist/demo.html +10 -0
- package/dist/static/css/chunk-src.895fe3a6.css +1 -0
- package/dist/static/img/demo.160f90e8.png +0 -0
- package/dist/static/img/demo.18a57edc.gif +0 -0
- package/dist/static/img/demo.c7910627.gif +0 -0
- package/dist/traffic-diagram.common.chunk-lodash.js +17212 -0
- package/dist/traffic-diagram.common.chunk-src.js +2015 -0
- package/dist/traffic-diagram.common.js +33788 -0
- package/dist/traffic-diagram.umd.chunk-lodash.js +17212 -0
- package/dist/traffic-diagram.umd.chunk-src.js +2015 -0
- package/dist/traffic-diagram.umd.js +33798 -0
- package/dist/traffic-diagram.umd.min.chunk-lodash.js +9 -0
- package/dist/traffic-diagram.umd.min.chunk-src.js +1 -0
- package/dist/traffic-diagram.umd.min.js +12 -0
- package/package.json +46 -0
- package/src/App.vue +269 -0
- package/src/assets/images/green-wave/demo.gif +0 -0
- package/src/assets/images/traffic-lane/demo.gif +0 -0
- package/src/assets/images/traffic-lane/demo.png +0 -0
- package/src/assets/images/traffic-lane/directon.png +0 -0
- package/src/assets/images/traffic-lane/left-ui.png +0 -0
- package/src/assets/images/traffic-lane/left.png +0 -0
- package/src/assets/images/traffic-lane/leftRight-ui.png +0 -0
- package/src/assets/images/traffic-lane/leftRight.png +0 -0
- package/src/assets/images/traffic-lane/otherPic-ui.png +0 -0
- package/src/assets/images/traffic-lane/otherPic.png +0 -0
- package/src/assets/images/traffic-lane/right-ui.png +0 -0
- package/src/assets/images/traffic-lane/right.png +0 -0
- package/src/assets/images/traffic-lane/straight-ui.png +0 -0
- package/src/assets/images/traffic-lane/straight.png +0 -0
- package/src/assets/images/traffic-lane/straightLeft-ui.png +0 -0
- package/src/assets/images/traffic-lane/straightLeft.png +0 -0
- package/src/assets/images/traffic-lane/straightLeftRight-ui.png +0 -0
- package/src/assets/images/traffic-lane/straightLeftRight.png +0 -0
- package/src/assets/images/traffic-lane/straightRight-ui.png +0 -0
- package/src/assets/images/traffic-lane/straightRight.png +0 -0
- package/src/assets/images/traffic-lane/turnAround-ui.png +0 -0
- package/src/assets/images/traffic-lane/turnAround.png +0 -0
- package/src/components/green-wave/index.vue +671 -0
- package/src/components/traffic-lane/index.vue +1020 -0
- package/src/index.js +32 -0
- package/src/libs/bus.js +24 -0
- package/src/libs/pics-load-tool.js +23 -0
- package/src/main.js +14 -0
- package/vue.config.js +279 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## 更新内容
|
|
2
|
+
|
|
3
|
+
### 1. 修正示例代码中的prop名称
|
|
4
|
+
- 将示例中的`origin-data`改为`lane-diagram-data`
|
|
5
|
+
- 确保示例代码与组件实际props名称一致
|
|
6
|
+
|
|
7
|
+
### 2. 完善Traffic Lane Component的Props参数表格
|
|
8
|
+
添加所有当前组件支持的props参数,包括:
|
|
9
|
+
- **laneDiagramData**: 画布数据,包含车道ID、方向等信息
|
|
10
|
+
- **canvasHeight**: 画布高度
|
|
11
|
+
- **configType**: 配置类型,用于车道流向配置
|
|
12
|
+
- **laneWidth**: 车道宽度
|
|
13
|
+
- **laneDividerLength**: 车道分隔线长度
|
|
14
|
+
- **laneDirections**: 车道方向配置
|
|
15
|
+
- **maxCongestionValue**: 拥堵值最大值
|
|
16
|
+
- **clickEvent**: 是否启用点击事件
|
|
17
|
+
- **congestionFactorVisible**: 是否显示拥堵指标值
|
|
18
|
+
- **multiple**: 是否支持多选
|
|
19
|
+
- **selectedLane**: 已选择的车道
|
|
20
|
+
- **laneActiveColor**: 车道激活颜色
|
|
21
|
+
|
|
22
|
+
### 3. 添加事件文档
|
|
23
|
+
记录组件触发的事件:
|
|
24
|
+
- **chooseLane**: 多选时车道选择事件
|
|
25
|
+
- **selectLane**: 单选时车道选择事件
|
|
26
|
+
- **changeLaneDir**: 车道方向变更事件
|
|
27
|
+
|
|
28
|
+
### 4. 确保文档一致性
|
|
29
|
+
- 组件名称使用`traffic-line`
|
|
30
|
+
- 术语统一为"Traffic Lane"而非"Traffic Line"
|
|
31
|
+
- 更新项目结构中的构建目录为`dist/`
|
|
32
|
+
|
|
33
|
+
## 预期效果
|
|
34
|
+
- README.md中Traffic Lane Component的文档完整准确
|
|
35
|
+
- Props参数表格详细,包含类型、默认值和描述
|
|
36
|
+
- 示例代码可直接使用
|
|
37
|
+
- 事件文档清晰明了
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## npm Publish Plan
|
|
2
|
+
|
|
3
|
+
### Overview
|
|
4
|
+
Publish the traffic-diagram package to npm registry.
|
|
5
|
+
|
|
6
|
+
### Prerequisites
|
|
7
|
+
- Project has proper package.json configuration
|
|
8
|
+
- .npmrc file configured with npm registry and auth token
|
|
9
|
+
- Package version is set to 1.0.7
|
|
10
|
+
|
|
11
|
+
### Steps
|
|
12
|
+
1. **Build the Project**
|
|
13
|
+
- Run `npm run build:lib` to generate the distributable files
|
|
14
|
+
- This will create the files specified in package.json's main and module fields
|
|
15
|
+
|
|
16
|
+
2. **Verify Build Output**
|
|
17
|
+
- Ensure dist/ directory contains all necessary files
|
|
18
|
+
- Check that traffic-diagram.umd.js, traffic-diagram.common.js, and other build artifacts are present
|
|
19
|
+
|
|
20
|
+
3. **Run npm Publish**
|
|
21
|
+
- Execute `npm publish` to publish the package to npm registry
|
|
22
|
+
- Verify the publish was successful
|
|
23
|
+
|
|
24
|
+
### Expected Results
|
|
25
|
+
- Package "traffic-diagram" version 1.0.7 is published to npm
|
|
26
|
+
- Package is publicly accessible on npmjs.com
|
|
27
|
+
- Users can install it using `npm install traffic-diagram`
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## 更新内容
|
|
2
|
+
|
|
3
|
+
### 1. 修正示例代码中的prop名称
|
|
4
|
+
|
|
5
|
+
* 将示例中的`origin-data`改为`lane-diagram-data`
|
|
6
|
+
|
|
7
|
+
* 确保示例代码与组件实际props名称一致
|
|
8
|
+
|
|
9
|
+
### 2. 完善Traffic Lane Component的Props参数表格
|
|
10
|
+
|
|
11
|
+
添加所有当前组件支持的props参数,包括:
|
|
12
|
+
|
|
13
|
+
* **laneDiagramData**: 画布数据,包含车道ID、方向等信息
|
|
14
|
+
|
|
15
|
+
* **canvasHeight**: 画布高度
|
|
16
|
+
|
|
17
|
+
* **configType**: 配置类型,用于车道流向配置
|
|
18
|
+
|
|
19
|
+
* **laneWidth**: 车道宽度
|
|
20
|
+
|
|
21
|
+
* **laneDividerLength**: 车道分隔线长度
|
|
22
|
+
|
|
23
|
+
* **laneDirections**: 车道方向配置
|
|
24
|
+
|
|
25
|
+
* **maxCongestionValue**: 拥堵值最大值
|
|
26
|
+
|
|
27
|
+
* **clickEvent**: 是否启用点击事件
|
|
28
|
+
|
|
29
|
+
* **congestionFactorVisible**: 是否显示拥堵指标值
|
|
30
|
+
|
|
31
|
+
* **multiple**: 是否支持多选
|
|
32
|
+
|
|
33
|
+
* **selectedLane**: 已选择的车道
|
|
34
|
+
|
|
35
|
+
* **laneActiveColor**: 车道激活颜色
|
|
36
|
+
|
|
37
|
+
### 3. 添加事件文档
|
|
38
|
+
|
|
39
|
+
记录组件触发的事件:
|
|
40
|
+
|
|
41
|
+
* **chooseLane**: 多选时车道选择事件
|
|
42
|
+
|
|
43
|
+
* **selectLane**: 单选时车道选择事件
|
|
44
|
+
|
|
45
|
+
* **changeLaneDir**: 车道方向变更事件
|
|
46
|
+
|
|
47
|
+
### 4. 确保文档一致性
|
|
48
|
+
|
|
49
|
+
* 组件名称使用`traffic-line`
|
|
50
|
+
|
|
51
|
+
* 术语统一为"Traffic Lane"而非"Traffic Line"
|
|
52
|
+
|
|
53
|
+
* 更新项目结构中的构建目录为`dist/`
|
|
54
|
+
|
|
55
|
+
## 预期效果
|
|
56
|
+
|
|
57
|
+
* README.md中Traffic Lane Component的文档完整准确
|
|
58
|
+
|
|
59
|
+
* Props参数表格详细,包含类型、默认值和描述
|
|
60
|
+
|
|
61
|
+
* 示例代码可直接使用
|
|
62
|
+
|
|
63
|
+
* 事件文档清晰明了
|
|
64
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## 更新README.md计划
|
|
2
|
+
|
|
3
|
+
### 1. 替换完整内容
|
|
4
|
+
将现有README.md文件替换为用户提供的完整更新内容,包括:
|
|
5
|
+
|
|
6
|
+
### 2. 主要更新点
|
|
7
|
+
- **修正组件导入名称**:将`greenWave`改为`GreenWave`
|
|
8
|
+
- **更新Green Wave组件**:
|
|
9
|
+
- 将`config` prop替换为`cross-data`
|
|
10
|
+
- 添加详细的props参数列表
|
|
11
|
+
- 添加事件文档
|
|
12
|
+
- 添加数据格式示例
|
|
13
|
+
- 添加演示GIF
|
|
14
|
+
- **完善Traffic Lane组件**:
|
|
15
|
+
- 修正导入名称为`TrafficLane`
|
|
16
|
+
- **保持其他部分不变**:
|
|
17
|
+
- 项目结构
|
|
18
|
+
- 开发命令
|
|
19
|
+
- 未来组件规划
|
|
20
|
+
- 许可证信息
|
|
21
|
+
|
|
22
|
+
### 3. 预期效果
|
|
23
|
+
README.md将包含完整的组件文档,用户可以清晰了解如何使用traffic-diagram库的所有功能。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
我将按照以下步骤进行npm发布:
|
|
2
|
+
|
|
3
|
+
1. **检查package.json配置**:确保package.json中的name、version、main、module等字段配置正确
|
|
4
|
+
2. **验证构建文件**:确认dist目录下包含所有必要的构建文件
|
|
5
|
+
3. **执行npm publish**:使用npm publish命令将包发布到npm registry
|
|
6
|
+
4. **验证发布结果**:检查npm registry上的发布状态
|
|
7
|
+
|
|
8
|
+
**注意事项**:
|
|
9
|
+
|
|
10
|
+
* 项目已经配置了正确的.npmrc文件,包含registry和auth token
|
|
11
|
+
|
|
12
|
+
* 项目版本已经更新到1.0.7
|
|
13
|
+
|
|
14
|
+
* 构建文件已经生成在dist目录下
|
|
15
|
+
|
|
16
|
+
**预期结果**:
|
|
17
|
+
|
|
18
|
+
* 包成功发布到npm registry
|
|
19
|
+
|
|
20
|
+
* 可以通过npm install traffic-diagram安装最新版本
|
|
21
|
+
|
|
22
|
+
* npm上显示的版本为1.0.7
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# traffic-diagram
|
|
2
|
+
|
|
3
|
+
Vue components for visualizing traffic diagrams, including lane schematics and green wave animations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Traffic Lane Component**: Interactive lane schematic visualization with click events and multiple selection support
|
|
8
|
+
- **Green Wave Component**: Animated green wave effect for traffic signal timing visualization
|
|
9
|
+
- **Responsive Design**: Adjustable dimensions and styles
|
|
10
|
+
- **PC Platform Support**: Optimized for desktop applications
|
|
11
|
+
|
|
12
|
+
## Effect Preview
|
|
13
|
+
|
|
14
|
+
### Lane Schematic Diagram
|
|
15
|
+
- 展示交通路口的车道布局和流向
|
|
16
|
+
- 支持不同方向车道的可视化
|
|
17
|
+
- 显示车道拥堵状态
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
### Interactive Operation
|
|
21
|
+
- 支持点击选择车道
|
|
22
|
+
- 支持车道方向配置
|
|
23
|
+
- 动态更新车道状态
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install traffic-diagram
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Dependencies
|
|
33
|
+
|
|
34
|
+
- `fabric@^5.5.2` - Canvas manipulation library
|
|
35
|
+
- `lodash` - Utility functions
|
|
36
|
+
- `vue@^2.6.14` - Vue framework
|
|
37
|
+
|
|
38
|
+
## Components
|
|
39
|
+
|
|
40
|
+
### Traffic Lane Component
|
|
41
|
+
|
|
42
|
+
Interactive lane schematic visualization for traffic intersections.
|
|
43
|
+
|
|
44
|
+
#### Usage
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<template>
|
|
48
|
+
<traffic-lane
|
|
49
|
+
:lane-diagram-data="laneDiagramData"
|
|
50
|
+
:lane-width="16"
|
|
51
|
+
:canvas-height="300"
|
|
52
|
+
:style="customStyle"
|
|
53
|
+
@choose-lane="handleLaneSelection"
|
|
54
|
+
multiple
|
|
55
|
+
click-event
|
|
56
|
+
></traffic-lane>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script>
|
|
60
|
+
import { trafficLane } from 'traffic-diagram';
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
components: {
|
|
64
|
+
trafficLane
|
|
65
|
+
},
|
|
66
|
+
data() {
|
|
67
|
+
return {
|
|
68
|
+
laneDiagramData: [
|
|
69
|
+
// Lane data array (see below for format)
|
|
70
|
+
],
|
|
71
|
+
customStyle: {
|
|
72
|
+
// Custom styles
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
handleLaneSelection(selectedLanes) {
|
|
78
|
+
// Handle lane selection event
|
|
79
|
+
console.log('Selected lanes:', selectedLanes);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Props
|
|
87
|
+
|
|
88
|
+
| Prop | Type | Default | Description |
|
|
89
|
+
|------|------|---------|-------------|
|
|
90
|
+
| `lane-diagram-data` | Array | `[]` | 画布数据,包含车道ID、方向、拥堵值等信息<br>字段描述:<br>- id: string - 车道ID<br>- laneDirCode: string - 车道方向编码<br>- laneDirName: string - 车道方向名称<br>- inDirection: string - 车道入口方向<br>- laneNo: number - 车道编号<br>- congestionFactor: number - 拥堵值 |
|
|
91
|
+
| `canvas-height` | Number | `300` | 画布高度 |
|
|
92
|
+
| `config-type` | String | `''` | 配置项,只有进行车道-流向配置时可在canvas图上点击替换方向图标<br>- Possible values:<br> - LaneConfig |
|
|
93
|
+
| `lane-width` | Number | `22` | 车道宽度 |
|
|
94
|
+
| `lane-divider-length` | Number | `80` | 车道分隔线长度 |
|
|
95
|
+
| `lane-directions` | Array | 预设方向数组 | 车道方向配置,包含方向名称和图标<br>默认值:左转、直行、右转、直左、左右、直右、直左右、掉头、其他 |
|
|
96
|
+
| `max-congestion-value` | Number | `1` | 拥堵值最大值,用于拥堵颜色计算 |
|
|
97
|
+
| `click-event` | Boolean | `false` | 是否启用点击事件 |
|
|
98
|
+
| `congestion-factor-visible` | Boolean | `false` | 是否在车道上显示拥堵指标值 |
|
|
99
|
+
| `multiple` | Boolean | `false` | 是否支持多选车道 |
|
|
100
|
+
| `selected-lane` | String | `''` | 已被选择的车道 |
|
|
101
|
+
| `lane-active-color` | String | `'#27ffd5'` | 车道激活颜色 |
|
|
102
|
+
| `style` | Object | `{}` | 组件自定义样式 |
|
|
103
|
+
|
|
104
|
+
#### Events
|
|
105
|
+
|
|
106
|
+
| Event | Description | Payload |
|
|
107
|
+
|-------|-------------|---------|
|
|
108
|
+
| `choose-lane` | 多选时车道选择事件,当用户选择或取消选择车道时触发 | Array - 已选择的车道名称数组 |
|
|
109
|
+
| `select-lane` | 单选时车道选择事件,当用户点击车道时触发 | Object - 包含选中车道信息<br>格式:{ laneDirCode: string } |
|
|
110
|
+
| `change-lane-dir` | 车道方向变更事件,当用户在配置模式下更改车道方向时触发 | Object - 包含车道编码和新方向<br>格式:{ laneDirCode: string, laneDirName: string } |
|
|
111
|
+
|
|
112
|
+
#### Data Format
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
// laneDiagramData format example
|
|
116
|
+
const laneDiagramData = [
|
|
117
|
+
{
|
|
118
|
+
"id": "unique-id",
|
|
119
|
+
"laneDirCode": "102",
|
|
120
|
+
"laneDirName": "直行",
|
|
121
|
+
"inDirection": "东",
|
|
122
|
+
"laneNo": "01",
|
|
123
|
+
"congestionFactor": 0.75
|
|
124
|
+
}
|
|
125
|
+
// More lane objects...
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
// Lane direction codes
|
|
129
|
+
const laneDirections = [
|
|
130
|
+
{ "id": "1", "laneDirCode": "101", "laneDirName": "左转", "remark": "L" },
|
|
131
|
+
{ "id": "2", "laneDirCode": "102", "laneDirName": "直行", "remark": "S" },
|
|
132
|
+
{ "id": "3", "laneDirCode": "103", "laneDirName": "右转", "remark": "R" },
|
|
133
|
+
{ "id": "4", "laneDirCode": "104", "laneDirName": "直左", "remark": "S_L" },
|
|
134
|
+
{ "id": "5", "laneDirCode": "105", "laneDirName": "直右", "remark": "S_R" },
|
|
135
|
+
{ "id": "6", "laneDirCode": "109", "laneDirName": "左右", "remark": "L_R" },
|
|
136
|
+
{ "id": "7", "laneDirCode": "106", "laneDirName": "直左右", "remark": "L_S_R" },
|
|
137
|
+
{ "id": "8", "laneDirCode": "107", "laneDirName": "掉头", "remark": "T" },
|
|
138
|
+
{ "id": "9", "laneDirCode": "108", "laneDirName": "其他", "remark": "O" }
|
|
139
|
+
];
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Green Wave Component
|
|
143
|
+
|
|
144
|
+
Animated green wave effect visualization for traffic signals.
|
|
145
|
+

|
|
146
|
+
|
|
147
|
+
#### Usage
|
|
148
|
+
|
|
149
|
+
```html
|
|
150
|
+
<template>
|
|
151
|
+
<green-wave
|
|
152
|
+
:cross-data="crossData"
|
|
153
|
+
:canvas-height="500"
|
|
154
|
+
:forward-direction="true"
|
|
155
|
+
:interval="70"
|
|
156
|
+
:style="customStyle"
|
|
157
|
+
@compute-data="handleComputeData"
|
|
158
|
+
@update-cross-params="handleUpdateParams"
|
|
159
|
+
></green-wave>
|
|
160
|
+
</template>
|
|
161
|
+
|
|
162
|
+
<script>
|
|
163
|
+
import { greenWave } from 'traffic-diagram';
|
|
164
|
+
|
|
165
|
+
export default {
|
|
166
|
+
components: {
|
|
167
|
+
greenWave
|
|
168
|
+
},
|
|
169
|
+
data() {
|
|
170
|
+
return {
|
|
171
|
+
crossData: [
|
|
172
|
+
// Green wave intersection data (see below for format)
|
|
173
|
+
],
|
|
174
|
+
customStyle: {
|
|
175
|
+
// Custom styles
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
methods: {
|
|
180
|
+
handleComputeData(data) {
|
|
181
|
+
// Handle computed green wave data
|
|
182
|
+
console.log('Computed data:', data);
|
|
183
|
+
},
|
|
184
|
+
handleUpdateParams(params) {
|
|
185
|
+
// Handle updated intersection parameters
|
|
186
|
+
console.log('Updated params:', params);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
</script>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### Props
|
|
194
|
+
|
|
195
|
+
| Prop | Type | Default | Description |
|
|
196
|
+
|------|------|---------|-------------|
|
|
197
|
+
| `cross-data` | Array | `[]` | 绿波路口数据<br>字段描述:<br>- crossId: string - 路口ID<br>- crossRoadName: string - 路口名称<br>- crossDistance: number - 路口距离<br>- orderNumber: number - 排序编号<br>- forwardGreen: number - 路口正向车道绿灯时长(A路口 -> B路口)<br>- reverseGreen: number - 路口反向车道绿灯时长(B路口 -> A路口)<br>- forwardSpeed: number - 路口正向车道速度(A路口 -> B路口)<br>- reverseSpeed: number - 路口反向车道速度(B路口 -> A路口)<br>- forwardPhaseDiff: number - 路口正向车道相位差时长(A路口 -> B路口)<br>- reversePhaseDiff: number - 路口反向车道相位差时长(B路口 -> A路口)<br>- greenFlag: boolean - 绿波标志<br>- phaseDiffFlag: boolean - 相位标志 |
|
|
198
|
+
| `canvas-height` | Number | `500` | 画布高度 |
|
|
199
|
+
| `forward-direction` | Boolean | `true` | 是否正向(从上到下, 从左到右为正方向) |
|
|
200
|
+
| `interval` | Number | `70` | 绿波周期间隔(单位:秒) |
|
|
201
|
+
| `forward-color` | String | `'#058213'` | 正向绿波颜色 |
|
|
202
|
+
| `backward-color` | String | `'#0eed28'` | 反向绿波颜色 |
|
|
203
|
+
| `drag-stroke-width` | Number | `5` | 拖拽线宽 |
|
|
204
|
+
| `single-wave-width` | Number | `2` | 单绿波宽度<br>值越小宽度越小,值越大宽度越大 |
|
|
205
|
+
| `x-axis-bottom` | Number | `30` | X轴底部间距 |
|
|
206
|
+
| `y-axis-top` | Number | `30` | Y轴顶部间距 |
|
|
207
|
+
| `y-axis-width` | Number | `200` | Y轴文本刻度宽度 |
|
|
208
|
+
| `loop-time` | Number | `0` | 绿波循环次数<br>- Possible values:<br> - 0 - 默认值,自动计算<br> - 1 - 循环一次 |
|
|
209
|
+
| `style` | Object | `{}` | 组件自定义样式 |
|
|
210
|
+
|
|
211
|
+
#### Events
|
|
212
|
+
|
|
213
|
+
| Event | Description | Payload |
|
|
214
|
+
|-------|-------------|---------|
|
|
215
|
+
| `compute-data` | 计算绿波数据事件,当绿波参数变化时触发 | Object - 包含绿波组数据<br>格式:{ groups_forward: Array, groups_back: Array, rate: Number, current_group?: Object } |
|
|
216
|
+
| `update-cross-params` | 更新路口参数事件,当拖拽调整绿波时触发 | Object - 包含更新的参数<br>格式:{ rate: Number, current_group: Object, direction: String } |
|
|
217
|
+
|
|
218
|
+
#### Data Format
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
// crossData format example
|
|
222
|
+
const crossData = [
|
|
223
|
+
{
|
|
224
|
+
"crossId": "cross-1",
|
|
225
|
+
"crossRoadName": "路口1",
|
|
226
|
+
"crossDistance": 500,
|
|
227
|
+
"orderNumber": 1,
|
|
228
|
+
"forwardGreen": 30,
|
|
229
|
+
"reverseGreen": 35,
|
|
230
|
+
"forwardSpeed": 40,
|
|
231
|
+
"reverseSpeed": 35,
|
|
232
|
+
"forwardPhaseDiff": 0,
|
|
233
|
+
"reversePhaseDiff": 10,
|
|
234
|
+
"greenFlag": true,
|
|
235
|
+
"phaseDiffFlag": true
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"crossId": "cross-2",
|
|
239
|
+
"crossRoadName": "路口2",
|
|
240
|
+
"crossDistance": 800,
|
|
241
|
+
"orderNumber": 2,
|
|
242
|
+
"forwardGreen": 35,
|
|
243
|
+
"reverseGreen": 30,
|
|
244
|
+
"forwardSpeed": 45,
|
|
245
|
+
"reverseSpeed": 40,
|
|
246
|
+
"forwardPhaseDiff": 15,
|
|
247
|
+
"reversePhaseDiff": 5,
|
|
248
|
+
"greenFlag": true,
|
|
249
|
+
"phaseDiffFlag": true
|
|
250
|
+
}
|
|
251
|
+
// More intersection objects...
|
|
252
|
+
];
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Project Structure
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
├── src/
|
|
259
|
+
│ ├── components/
|
|
260
|
+
│ │ ├── traffic-lane/ # Traffic lane component
|
|
261
|
+
│ │ └── green-wave/ # Green wave component
|
|
262
|
+
│ ├── libs/ # Utility libraries
|
|
263
|
+
│ ├── assets/ # Static assets
|
|
264
|
+
│ └── index.js # Main export file
|
|
265
|
+
├── dist/ # Built library files
|
|
266
|
+
└── package.json # Project configuration
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Development
|
|
270
|
+
|
|
271
|
+
### Build the Library
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
npm run build:lib
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Run Development Server
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npm run serve
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Run Tests
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
npm run test
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Linting
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
npm run eslint
|
|
293
|
+
npm run stylelint
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Future Components
|
|
297
|
+
|
|
298
|
+
This library is actively being developed. Future components will include:
|
|
299
|
+
|
|
300
|
+
- Traffic Signal Component
|
|
301
|
+
- Vehicle Flow Visualization
|
|
302
|
+
- Intersection Simulation
|
|
303
|
+
- Real-time Data Integration
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome! Please feel free to submit issues and pull requests.
|
package/dist/demo.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.crossing-box[data-v-52147a10]{margin:auto;position:relative}.legend-box[data-v-52147a10]{display:flex;justify-content:space-between;margin-top:20px;flex-wrap:wrap;width:180px;background:rgba(13,43,80,.9);padding:10px;z-index:999;position:absolute;left:0;top:0;transition:all .3s ease}.legend-box .legend-item[data-v-52147a10]{width:40px;border-radius:8px;padding:8px;margin-bottom:5px;font-size:12px;text-align:center;cursor:pointer}.legend-box .legend-item[data-v-52147a10]:hover{background:rgba(39,255,213,.7)}.legend-box .legend-item img[data-v-52147a10]{height:20px;margin-bottom:5px}[data-v-52147a10] .canvas-container{margin:auto}.canvas-wrapper[data-v-9b8515cc]{display:flex}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|