zcode-app-cli 3.3.5-1
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/LICENSE +24 -0
- package/README.md +642 -0
- package/bin/zcode.js +848 -0
- package/config.example.json +110 -0
- package/package.json +81 -0
- package/vendor/.node-bundle-meta.json +6 -0
- package/vendor/extraction.json +11 -0
- package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
- package/vendor/node_modules/@zcode/tui/package.json +14 -0
- package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
- package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
- package/vendor/packages/android-emulator-plugin/README.md +134 -0
- package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
- package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
- package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
- package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
- package/vendor/packages/android-emulator-plugin/package.json +35 -0
- package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
- package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
- package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
- package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/document-skills-plugin/package.json +8 -0
- package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
- package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
- package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
- package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
- package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
- package/vendor/packages/ios-simulator-plugin/README.md +111 -0
- package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
- package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
- package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
- package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
- package/vendor/packages/ios-simulator-plugin/package.json +35 -0
- package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
- package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
- package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
- package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
- package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
- package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
- package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/skill-creator-plugin/package.json +8 -0
- package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
- package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/zcode-guide-plugin/README.md +22 -0
- package/vendor/packages/zcode-guide-plugin/package.json +8 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
- package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
- package/vendor/zcode.cjs +2926 -0
- package/zcode-runtime.lock.json +8 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Chart Design — Chart Typesetting & Anti-Stacking Rules
|
|
2
|
+
|
|
3
|
+
> Core principle: **Data-Ink Ratio** — delete every line that doesn't represent data. Then delete some more.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Part 1: Anti-Stacking (Collision Prevention)
|
|
8
|
+
|
|
9
|
+
Text stacking is fundamentally "information density exceeding available physical space." Apply these dynamic degradation strategies.
|
|
10
|
+
|
|
11
|
+
### 0. Universal Anti-Overlap Pre-Check (MANDATORY)
|
|
12
|
+
|
|
13
|
+
**Before rendering ANY chart, run this pre-flight check:**
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
# Step 1: Reserve space for labels FIRST, then draw chart
|
|
17
|
+
# WRONG: draw chart → add labels → discover overlap → cry
|
|
18
|
+
# RIGHT: measure labels → reserve space → draw chart in remaining area
|
|
19
|
+
|
|
20
|
+
# Step 2: Chart-to-text separation
|
|
21
|
+
CHART_TEXT_MIN_GAP = 12 # pt — minimum gap between chart edge and adjacent text
|
|
22
|
+
CHART_LABEL_MIN_GAP = 6 # pt — minimum gap between chart labels and chart elements
|
|
23
|
+
|
|
24
|
+
# Step 3: Label-to-label collision check
|
|
25
|
+
def labels_overlap(label_a, label_b):
|
|
26
|
+
"""Check if two label bounding boxes overlap."""
|
|
27
|
+
return not (label_a.right < label_b.left or
|
|
28
|
+
label_a.left > label_b.right or
|
|
29
|
+
label_a.bottom < label_b.top or
|
|
30
|
+
label_a.top > label_b.bottom)
|
|
31
|
+
|
|
32
|
+
# Step 4: Resolution cascade
|
|
33
|
+
# 1. Reposition (nudge conflicting label)
|
|
34
|
+
# 2. Reduce font size (min 8pt)
|
|
35
|
+
# 3. Remove label (replace with legend entry)
|
|
36
|
+
# 4. Merge small items ("Others" grouping)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Matplotlib-specific anti-overlap:**
|
|
40
|
+
```python
|
|
41
|
+
# MANDATORY for all matplotlib charts
|
|
42
|
+
import matplotlib.pyplot as plt
|
|
43
|
+
from adjustText import adjust_text # pip install adjustText
|
|
44
|
+
|
|
45
|
+
# After adding text annotations:
|
|
46
|
+
# adjust_text(texts, arrowprops=dict(arrowstyle='-', color='gray', lw=0.5))
|
|
47
|
+
|
|
48
|
+
# For bar value labels:
|
|
49
|
+
fig.tight_layout(pad=2.0) # Always use generous padding
|
|
50
|
+
plt.subplots_adjust(bottom=0.15) # Reserve space for rotated labels
|
|
51
|
+
|
|
52
|
+
# For pie/donut:
|
|
53
|
+
# autopct labels: check angular distance between adjacent slices
|
|
54
|
+
# If angle < 15°, use external labels with leader lines
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Chart-to-body-text separation (ReportLab):**
|
|
58
|
+
```python
|
|
59
|
+
# MANDATORY spacers around chart flowables
|
|
60
|
+
story.append(Spacer(1, 24)) # 24pt gap before chart
|
|
61
|
+
story.append(chart_image) # Chart
|
|
62
|
+
story.append(Spacer(1, 8)) # 8pt gap
|
|
63
|
+
story.append(chart_caption) # Caption
|
|
64
|
+
story.append(Spacer(1, 24)) # 24pt gap after chart
|
|
65
|
+
# NEVER place chart without Spacer guards
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 1. Pie / Donut Chart — Label Collision Prevention
|
|
69
|
+
|
|
70
|
+
When slices are too small, labels MUST NOT be placed inside the arc.
|
|
71
|
+
|
|
72
|
+
#### Strategy A: Leader Lines + Y-Axis Collision Avoidance
|
|
73
|
+
|
|
74
|
+
When slice angle `< 15°` (or area share `< 5%`), force external labels:
|
|
75
|
+
- Draw a polyline (leader line) from the arc's outer edge to the label text
|
|
76
|
+
- **Y-axis anti-collision logic**: Calculate adjacent label Y-coordinates. If `Y2 - Y1 < font_height + padding`, push `Y2` downward (or pull `Y1` upward). Extend/shorten the horizontal segment of the leader line accordingly.
|
|
77
|
+
- Leader lines: 1pt, same color as slice at 60% opacity
|
|
78
|
+
|
|
79
|
+
#### Strategy B: "Others" Grouping (Long-Tail Merge)
|
|
80
|
+
|
|
81
|
+
Before data reaches the renderer, intercept and merge:
|
|
82
|
+
- Threshold: slices `< 3%` → merge into a single "其他 (Others)" slice
|
|
83
|
+
- If detail is needed, add a minimal table beside the chart showing the breakdown
|
|
84
|
+
- This prevents 5+ tiny slivers from cluttering the chart
|
|
85
|
+
|
|
86
|
+
#### Strategy C: Strip Labels, Use Rich Legend
|
|
87
|
+
|
|
88
|
+
The most premium approach — **zero text on the chart itself**:
|
|
89
|
+
- Pie/donut body shows only pure shapes + colors
|
|
90
|
+
- All names, percentages, and values are laid out in a grid-aligned legend to the right or below
|
|
91
|
+
- This NEVER stacks, and looks the most professional
|
|
92
|
+
|
|
93
|
+
**Priority order**: C (best) → A (good) → B (acceptable fallback)
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### 2. Bar Chart — Label Collision Prevention
|
|
98
|
+
|
|
99
|
+
#### Strategy A: Auto-Rotate to Horizontal Bar
|
|
100
|
+
|
|
101
|
+
**Hard rule**: When X-axis label average length exceeds **5 Chinese characters** (or 10 Latin characters), automatically convert to a horizontal bar chart.
|
|
102
|
+
- Y-axis has unlimited downward space for labels — stacking is impossible
|
|
103
|
+
- This is the single most effective anti-collision measure for bar charts
|
|
104
|
+
|
|
105
|
+
#### Strategy B: Tick Thinning + Stagger
|
|
106
|
+
|
|
107
|
+
When there are many bars (e.g., 30-day trend):
|
|
108
|
+
- **Thinning**: Show every 2nd or 5th label (skip intermediate ticks)
|
|
109
|
+
- **Stagger**: Alternate labels between two rows (offset vertically)
|
|
110
|
+
- **Tilt (last resort)**: 45° rotation works but reduces readability in premium reports. Prefer thinning or horizontal bars.
|
|
111
|
+
|
|
112
|
+
#### Strategy C: Value Label Inside/Outside Flip
|
|
113
|
+
|
|
114
|
+
- If bar is tall enough: place value label **inside** the bar near the top (use contrasting text color)
|
|
115
|
+
- If bar is too short for internal label: place value **above** the bar
|
|
116
|
+
- If value labels would overlap between adjacent bars: show values only on the tallest/shortest bars, or use tooltip-style callout boxes
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### 3. Line Chart — Data Point Label Prevention
|
|
121
|
+
|
|
122
|
+
Dense data points with labels on every point = visual chaos.
|
|
123
|
+
|
|
124
|
+
#### Strategy A: "First, Last, Max, Min" Rule (Data Journalism Standard)
|
|
125
|
+
|
|
126
|
+
Only auto-label **4 points** on any line:
|
|
127
|
+
- **Start point** (first value)
|
|
128
|
+
- **End point** (last value)
|
|
129
|
+
- **Maximum** (peak)
|
|
130
|
+
- **Minimum** (valley)
|
|
131
|
+
|
|
132
|
+
All other points show only the curve shape — no labels. This instantly elevates professionalism.
|
|
133
|
+
|
|
134
|
+
#### Strategy B: Callout Boxes
|
|
135
|
+
|
|
136
|
+
For points that must be highlighted:
|
|
137
|
+
- Don't let text sit naked on the curve
|
|
138
|
+
- Wrap in a rounded-corner background box (white fill, very light shadow or thin border)
|
|
139
|
+
- Connect to the data point with a thin needle line
|
|
140
|
+
- Boxes have physical boundaries → easier collision detection and displacement
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Part 2: Visual Refinement (Eliminating "Cheap" Aesthetics)
|
|
145
|
+
|
|
146
|
+
### 1. Axis & Grid Line Treatment
|
|
147
|
+
|
|
148
|
+
**The #1 sign of amateur charts: thick black border frames and solid grid lines.**
|
|
149
|
+
|
|
150
|
+
| Element | Rule |
|
|
151
|
+
|---------|------|
|
|
152
|
+
| Top spine | **DELETE** (unconditionally) |
|
|
153
|
+
| Right spine | **DELETE** (unconditionally) |
|
|
154
|
+
| Left Y-axis spine | Optional — can delete if values are labeled on bars directly |
|
|
155
|
+
| Bottom X-axis | Keep as baseline reference (thin, gray) |
|
|
156
|
+
| Grid lines | **Dashed only** (dotted or dashed), 0.5pt, 15-20% opacity. NEVER solid. |
|
|
157
|
+
| Grid lines (when values shown) | **DELETE entirely** — if bar/line values are directly labeled, grid lines are redundant |
|
|
158
|
+
|
|
159
|
+
### 2. Geometric Shape Refinement
|
|
160
|
+
|
|
161
|
+
#### Pie → Donut (Mandatory Default)
|
|
162
|
+
|
|
163
|
+
- **Always use donut (ring) charts** instead of solid pies
|
|
164
|
+
- Inner radius = **60–70%** of outer radius
|
|
165
|
+
- Center space: display the total value or core metric in large text (e.g., "100%" / "¥2.4M")
|
|
166
|
+
- Visual weight is lighter, information hierarchy is clearer
|
|
167
|
+
|
|
168
|
+
#### Bar Styling
|
|
169
|
+
|
|
170
|
+
| Property | Value | Why |
|
|
171
|
+
|----------|-------|-----|
|
|
172
|
+
| Bar-to-gap ratio | `1.5:1` or `2:1` | Not too thin (bamboo sticks), not too fat (no breathing room) |
|
|
173
|
+
| Top border-radius | `2px – 4px` | Micro-rounding removes machine harshness, adds modern UI feel |
|
|
174
|
+
| Bottom border-radius | `0px` | Flat base anchors to the axis |
|
|
175
|
+
|
|
176
|
+
#### Line Chart Refinement
|
|
177
|
+
|
|
178
|
+
| Property | Value | Why |
|
|
179
|
+
|----------|-------|-----|
|
|
180
|
+
| Curve type | **Smooth (Bézier/spline)** | Unless showing strictly discrete data |
|
|
181
|
+
| Line width | `2pt – 3pt` | Stands out against weakened grid |
|
|
182
|
+
| Area fill | Gradient from line color at 20% opacity → 0% opacity downward | Adds volume and depth |
|
|
183
|
+
| Data point markers | Small circles (3-4px radius), only on labeled points | Don't mark every point |
|
|
184
|
+
|
|
185
|
+
### 3. Legend & Text Hierarchy
|
|
186
|
+
|
|
187
|
+
#### Chart Title Layout
|
|
188
|
+
|
|
189
|
+
- **Main title**: Left-aligned above the chart, bold, 14-16pt
|
|
190
|
+
- **Subtitle**: Below main title, regular weight, smaller (11-12pt), describes data source/period/units
|
|
191
|
+
- Title and chart body must have clear visual separation (≥16px gap)
|
|
192
|
+
|
|
193
|
+
#### Legend Rules
|
|
194
|
+
|
|
195
|
+
| Rule | Details |
|
|
196
|
+
|------|---------|
|
|
197
|
+
| Border | **NONE** — never put a box around the legend |
|
|
198
|
+
| Position | Top-left horizontal row (preferred) or directly above chart area |
|
|
199
|
+
| Markers | Small circles (4px) or short line segments — NOT chunky squares |
|
|
200
|
+
| Font size | Same as axis labels (10-12pt) |
|
|
201
|
+
| Spacing | Generous horizontal spacing between items (≥24px) |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Part 3: Default Chart Configuration
|
|
206
|
+
|
|
207
|
+
When generating any chart (HTML/SVG for Creative pipeline, or matplotlib/ReportLab for Report pipeline), apply these defaults:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
Chart Defaults:
|
|
211
|
+
axes:
|
|
212
|
+
top_spine: hidden
|
|
213
|
+
right_spine: hidden
|
|
214
|
+
left_spine: light_gray_or_hidden
|
|
215
|
+
bottom_spine: light_gray_thin
|
|
216
|
+
grid: dashed, 0.5pt, 20% opacity (or hidden if values labeled)
|
|
217
|
+
|
|
218
|
+
pie:
|
|
219
|
+
type: donut
|
|
220
|
+
hole_ratio: 0.65
|
|
221
|
+
min_slice_for_internal_label: 5%
|
|
222
|
+
small_slice_strategy: leader_lines # or "others_merge" or "rich_legend"
|
|
223
|
+
others_threshold: 3%
|
|
224
|
+
|
|
225
|
+
bar:
|
|
226
|
+
top_radius: 3px
|
|
227
|
+
bar_gap_ratio: 0.5 # gap = 50% of bar width
|
|
228
|
+
auto_horizontal_threshold: 5_cjk_chars # or 10 latin chars
|
|
229
|
+
value_label_position: auto # inside if tall, outside if short
|
|
230
|
+
|
|
231
|
+
line:
|
|
232
|
+
smooth: true # Bézier curve
|
|
233
|
+
width: 2.5pt
|
|
234
|
+
area_fill: gradient_20_to_0
|
|
235
|
+
label_strategy: first_last_max_min
|
|
236
|
+
point_markers: labeled_points_only
|
|
237
|
+
|
|
238
|
+
legend:
|
|
239
|
+
border: none
|
|
240
|
+
position: top_left_horizontal
|
|
241
|
+
marker_shape: circle_small # 4px radius
|
|
242
|
+
marker_size: 4px
|
|
243
|
+
|
|
244
|
+
typography:
|
|
245
|
+
chart_title: bold, 14-16pt, left-aligned
|
|
246
|
+
chart_subtitle: regular, 11-12pt, left-aligned
|
|
247
|
+
axis_labels: 10-12pt
|
|
248
|
+
value_labels: 10-12pt
|
|
249
|
+
legend_text: 10-12pt
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Part 4: Pipeline-Specific Notes
|
|
255
|
+
|
|
256
|
+
### Creative Pipeline (Playwright HTML/CSS)
|
|
257
|
+
|
|
258
|
+
Charts in the Creative pipeline are rendered as HTML/SVG within the blueprint's components. Apply chart rules through:
|
|
259
|
+
- Inline SVG with proper viewBox and text positioning
|
|
260
|
+
- CSS classes for axis hiding, grid styling, legend layout
|
|
261
|
+
- JavaScript-based collision detection for leader lines (if dynamic)
|
|
262
|
+
|
|
263
|
+
### Report Pipeline (ReportLab)
|
|
264
|
+
|
|
265
|
+
Charts in the Report pipeline use ReportLab Drawing objects or embedded matplotlib figures:
|
|
266
|
+
- Use matplotlib with `plt.rcParams` overrides matching the defaults above
|
|
267
|
+
- `ax.spines['top'].set_visible(False)`, `ax.spines['right'].set_visible(False)`
|
|
268
|
+
- `ax.grid(True, linestyle='--', alpha=0.2, linewidth=0.5)`
|
|
269
|
+
- For pie charts: `plt.pie(..., wedgeprops=dict(width=0.35))` for donut effect
|
|
270
|
+
- For bar charts: use `matplotlib.patches.FancyBboxPatch` or `bar(..., edgecolor='none')` with manual rounded rect patches
|
|
271
|
+
|
|
272
|
+
### Academic Pipeline (LaTeX/TikZ)
|
|
273
|
+
|
|
274
|
+
- Use `pgfplots` with similar axis/grid configuration
|
|
275
|
+
- `\pgfplotsset{every axis/.append style={...}}`
|
|
276
|
+
- Donut charts via `tikz` with arc drawing
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Part 5: Chart Spacing & Anti-Overlap Guarantees
|
|
281
|
+
|
|
282
|
+
### 5.1 Chart-to-Body-Text Separation
|
|
283
|
+
|
|
284
|
+
| Context | Minimum Gap | Notes |
|
|
285
|
+
|---------|-------------|-------|
|
|
286
|
+
| Chart above/below body text | 24pt | Both above and below the chart |
|
|
287
|
+
| Chart caption to chart | 8pt | Caption immediately below chart |
|
|
288
|
+
| Chart caption to next body text | 18pt | Clear separation |
|
|
289
|
+
| Two consecutive charts | 30pt | Prevent visual merging |
|
|
290
|
+
|
|
291
|
+
### 5.2 Legend-to-Chart Overlap Prevention
|
|
292
|
+
|
|
293
|
+
**Legend MUST NOT overlap chart data area.** This is a zero-tolerance rule.
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
# matplotlib: move legend outside plot area when overlapping
|
|
297
|
+
leg = ax.legend(loc='upper left', bbox_to_anchor=(0, 1), frameon=False)
|
|
298
|
+
# If legend still overlaps, move to below chart:
|
|
299
|
+
# leg = ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12),
|
|
300
|
+
# ncol=3, frameon=False)
|
|
301
|
+
|
|
302
|
+
# ALWAYS call tight_layout AFTER placing legend
|
|
303
|
+
fig.tight_layout()
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### 5.3 Value Label Anti-Collision
|
|
307
|
+
|
|
308
|
+
**When value labels on adjacent bars/points overlap:**
|
|
309
|
+
1. **Stagger vertically** — alternate above/below the bar
|
|
310
|
+
2. **Rotate 45°** — angled labels take less horizontal space
|
|
311
|
+
3. **Show only key values** — max, min, first, last
|
|
312
|
+
4. **Remove all and use gridlines** — let the reader estimate from axis
|
|
313
|
+
|
|
314
|
+
### 5.4 Multi-Chart Layout in Documents
|
|
315
|
+
|
|
316
|
+
When a page contains 2+ charts:
|
|
317
|
+
- Each chart gets its own bounding box with explicit dimensions
|
|
318
|
+
- Charts must not share the same vertical space (no side-by-side unless explicitly designed)
|
|
319
|
+
- For side-by-side charts: use a 2-column layout with `Spacer` between columns
|
|
320
|
+
- Each chart’s title/subtitle/legend must be fully within its own bounding box
|