EChart Data Analysis Skill
Use this skill to turn structured data into evidence-backed analysis and
standalone ECharts deliverables. The invariant is not “an HTML file exists”; it
is that the data, metric definition, analysis claim, visual expression, and live
browser result all reconcile.
Required pipeline
Follow these stages for every analysis. Read only the references needed for the
requested deliverable.
- Resolve data and business scope
- Inspect schema with maintained CLIs; do not load large tables into context.
- Run
python scripts/metrics_manager.py effective before defining metrics,
filters, governed entity sets, comparison scope, or business terminology.
- Never invent fields or approximate a governed set with keyword matching.
- Assess data fitness
- Check date coverage, incomplete periods, nulls, duplicates, grain,
uniqueness, units, currency, timezone, status filters, and known exclusions.
- Use
scripts/data_quality.py or scripts/data_contract.py when relevant.
- Query through the audited execution path
- Generate reviewable SQL and execute it with
scripts/sql_runner.py,
scripts/db_cli.py, or scripts/db_manager.py.
- Never write temporary database connection code, heredoc Python,
duckdb.connect, psycopg.connect, pymysql.connect, create_engine,
.cursor(), or cur.execute().
- Write query results with
--out so query hash and lineage metadata exist.
- Plan the analytical expression
- Read analysis expression quality.
- Write an analysis-plan JSON and run
python scripts/validate_analysis_plan.py <plan.json>.
- Use Message → Relation → View. Select views through
references/chart_capabilities.json or
python scripts/chart_capabilities.py <view-request.json>.
- Distinguish the hidden audit/source table from a visible analytical
companion table.
- Bind evidence instead of restating it
- Read
workflow_specs/artifact_evidence_contract.md.
- Create a draft artifact manifest that references actual query result files.
- Run
python scripts/artifact_manifest.py bind <output.html> <draft.json>.
- The binder computes query-result SHA-256, row count, date coverage, and
binds query hashes, metric/scope fingerprints, comparisons, charts, and
findings into the HTML.
- Render from maintained recipes and templates
- Read
references/examples/INDEX.md, then the selected recipe completely.
- Dashboard: read
workflow_specs/dashboard_workflow.md and
workflow_specs/dashboard_runtime_quality.md.
- Report: read
workflow_specs/report_workflow.md.
- Use
workflow_specs/html_templates/dashboard_light.html or
workflow_specs/html_templates/report_light.html as the relevant shell.
- Run the complete delivery gate
- Run
python scripts/validate_delivery.py <output.html>.
- This combines static ECharts/runtime checks, governance checks, manifest
reconciliation, and a real Playwright/Chromium render.
- Any console error, page error, external request, missing ECharts instance,
zero-size canvas/SVG, evidence mismatch, or invalid comparison blocks
delivery.
--allow-static-only is a degraded exception only when browser execution
is genuinely unavailable; disclose that reduced assurance.
SQL execution contract
Preferred examples:
python scripts/schema_manager.py show <table>
python scripts/sql_runner.py --db workspace.duckdb --file queries/<task>.sql \
--output json --out outputs/query_results/<task>.json
python scripts/sql_runner.py --profile <profile> --file queries/<task>.sql \
--output json --out outputs/query_results/<task>.json
For one-off external connections, pass credentials only through approved
environment-backed CLI parameters such as --password-env or --dsn-env.
Project queries, connection profiles, outputs, logs, and generated packages are
local state and must never be added to the reusable skill release.
Comparison and metric correctness
All YoY, QoQ, MoM, WoW, period, and cohort comparisons must declare:
- current and baseline start/end;
- complete or partial status;
- latest complete period;
- calendar type: calendar, fiscal, retail 4-4-5, or custom;
- alignment rule and comparability;
- visible current/baseline labels;
- evidence query IDs and metric IDs;
- identical current/baseline fingerprints for metric definition, entity scope,
filters, unit, currency, and timezone.
YTD-versus-full-year and partial-versus-complete comparisons are blocking
failures. Fiscal and retail calendars align governed named periods rather than
being forced onto calendar-month boundaries.
An HTML comparison must contain both analysis-comparison-contract and
analysis-artifact-manifest. The declared windows must match each other and the
actual dates in the bound query result files.
Findings and analytical depth
Every major finding must state What, baseline, Why status, Why, So what, next
check, evidence references, and limitations.
tested: allowed only when the artifact manifest references an executed next
check query.
hypothesis: a plausible explanation that still needs testing.
unknown: insufficient evidence; state the missing data.
Correlation, ranking, trend, anomaly, and composition detectors produce
descriptive candidates, not causal conclusions. Drill down through contribution,
segment, volume × rate/price, anomaly/data-quality, and stability/sample-size
checks when the data supports them.
Visual and table contract
- Prefer position and length encodings over angle, area, volume, and decorative
effects.
- A pie chart is limited to 2–3 positive categories and approximate share.
- Use a visible companion table for exact lookup, high-density comparison,
exceptions, risk/action lists, or four-plus measures.
- Every chart still needs a default-hidden
查看数据 source table, chart-level
statistical scope, data source, and evidence/query reference.
- Include units, readable labels, semantic colors, responsive sizing, and a
text/table fallback. Do not rely on color alone.
- Do not invent a product, brand, industry label, or title that is absent from
the request, governed scope, schema, and evidence.
- Mixed bar/line charts with different units or magnitudes require separate
y-axes and explicit
yAxisIndex: 0 / yAxisIndex: 1 assignment.
Standalone HTML and runtime contract
- Inline ECharts and required local assets; no CDN, runtime loader,
fetch() to
external URLs, iframe/object/embed, self-navigation, or file:// nesting.
- Load libraries before chart bootstrap. Use literal
</script> closing tags.
- Serialize data with
json.dumps(..., ensure_ascii=False, default=str); never
hand-write large JavaScript data objects or call JSON.parse({...}).
- Use real responsive chart dimensions and resize handling.
- Dashboard runtime rules cover map registration including accidental
chinaGeoJSON references, PDF export compatibility including color-mix(),
card/grid density, data-table controls, and export/download behavior.
Routing references
| Request |
Read |
| Import or cleaning |
workflow_specs/data_cleaning_workflow.md |
| Chart selection |
workflow_specs/analysis_expression_quality.md, references/chart_capabilities.json |
| Dashboard |
workflow_specs/dashboard_workflow.md, workflow_specs/dashboard_runtime_quality.md |
| Report |
workflow_specs/report_workflow.md |
| Domain analysis |
workflow_specs/expert_library/INDEX.md |
| Domain dashboard |
workflow_specs/dashboard_expert_library/INDEX.md |
| Individual commands or CLI detail |
commands/echart/*.md |
When adding a reusable dashboard expert, start from
workflow_specs/dashboard_expert_library/DASHBOARD_EXPERT_TEMPLATE.md; never
place a project-specific dashboard or query in the skill.
Release hygiene
Run:
bash package.sh
python scripts/validate_release_package.py dist/<package>.zip
The package uses an allowlist. Project SQL, database connection files, outputs,
logs, caches, tests, and local indexes are forbidden release content.
1---2name: echart-skill3description: 使用本地 SQL/DuckDB 分析 Excel、CSV 或数据库数据,并生成可审计、可离线运行的 ECharts 图表、Dashboard 和分析报告。适用于数据导入、清洗、查询、同比环比、诊断分析、可视化和企业 BI 交付。4---56# EChart Data Analysis Skill78Use this skill to turn structured data into evidence-backed analysis and9standalone ECharts deliverables. The invariant is not “an HTML file exists”; it10is that the data, metric definition, analysis claim, visual expression, and live11browser result all reconcile.1213## Required pipeline1415Follow these stages for every analysis. Read only the references needed for the16requested deliverable.17181. **Resolve data and business scope**19 - Inspect schema with maintained CLIs; do not load large tables into context.20 - Run `python scripts/metrics_manager.py effective` before defining metrics,21 filters, governed entity sets, comparison scope, or business terminology.22 - Never invent fields or approximate a governed set with keyword matching.232. **Assess data fitness**24 - Check date coverage, incomplete periods, nulls, duplicates, grain,25 uniqueness, units, currency, timezone, status filters, and known exclusions.26 - Use `scripts/data_quality.py` or `scripts/data_contract.py` when relevant.273. **Query through the audited execution path**28 - Generate reviewable SQL and execute it with `scripts/sql_runner.py`,29 `scripts/db_cli.py`, or `scripts/db_manager.py`.30 - Never write temporary database connection code, heredoc Python,31 `duckdb.connect`, `psycopg.connect`, `pymysql.connect`, `create_engine`,32 `.cursor()`, or `cur.execute()`.33 - Write query results with `--out` so query hash and lineage metadata exist.344. **Plan the analytical expression**35 - Read [analysis expression quality](workflow_specs/analysis_expression_quality.md).36 - Write an analysis-plan JSON and run37 `python scripts/validate_analysis_plan.py <plan.json>`.38 - Use Message → Relation → View. Select views through39 `references/chart_capabilities.json` or40 `python scripts/chart_capabilities.py <view-request.json>`.41 - Distinguish the hidden audit/source table from a visible analytical42 companion table.435. **Bind evidence instead of restating it**44 - Read `workflow_specs/artifact_evidence_contract.md`.45 - Create a draft artifact manifest that references actual query result files.46 - Run `python scripts/artifact_manifest.py bind <output.html> <draft.json>`.47 - The binder computes query-result SHA-256, row count, date coverage, and48 binds query hashes, metric/scope fingerprints, comparisons, charts, and49 findings into the HTML.506. **Render from maintained recipes and templates**51 - Read `references/examples/INDEX.md`, then the selected recipe completely.52 - Dashboard: read `workflow_specs/dashboard_workflow.md` and53 `workflow_specs/dashboard_runtime_quality.md`.54 - Report: read `workflow_specs/report_workflow.md`.55 - Use `workflow_specs/html_templates/dashboard_light.html` or56 `workflow_specs/html_templates/report_light.html` as the relevant shell.577. **Run the complete delivery gate**58 - Run `python scripts/validate_delivery.py <output.html>`.59 - This combines static ECharts/runtime checks, governance checks, manifest60 reconciliation, and a real Playwright/Chromium render.61 - Any console error, page error, external request, missing ECharts instance,62 zero-size canvas/SVG, evidence mismatch, or invalid comparison blocks63 delivery.64 - `--allow-static-only` is a degraded exception only when browser execution65 is genuinely unavailable; disclose that reduced assurance.6667## SQL execution contract6869Preferred examples:7071```bash72python scripts/schema_manager.py show <table>73python scripts/sql_runner.py --db workspace.duckdb --file queries/<task>.sql \74 --output json --out outputs/query_results/<task>.json75python scripts/sql_runner.py --profile <profile> --file queries/<task>.sql \76 --output json --out outputs/query_results/<task>.json77```7879For one-off external connections, pass credentials only through approved80environment-backed CLI parameters such as `--password-env` or `--dsn-env`.81Project queries, connection profiles, outputs, logs, and generated packages are82local state and must never be added to the reusable skill release.8384## Comparison and metric correctness8586All YoY, QoQ, MoM, WoW, period, and cohort comparisons must declare:8788- current and baseline start/end;89- complete or partial status;90- latest complete period;91- calendar type: calendar, fiscal, retail 4-4-5, or custom;92- alignment rule and comparability;93- visible current/baseline labels;94- evidence query IDs and metric IDs;95- identical current/baseline fingerprints for metric definition, entity scope,96 filters, unit, currency, and timezone.9798YTD-versus-full-year and partial-versus-complete comparisons are blocking99failures. Fiscal and retail calendars align governed named periods rather than100being forced onto calendar-month boundaries.101102An HTML comparison must contain both `analysis-comparison-contract` and103`analysis-artifact-manifest`. The declared windows must match each other and the104actual dates in the bound query result files.105106## Findings and analytical depth107108Every major finding must state What, baseline, Why status, Why, So what, next109check, evidence references, and limitations.110111- `tested`: allowed only when the artifact manifest references an executed next112 check query.113- `hypothesis`: a plausible explanation that still needs testing.114- `unknown`: insufficient evidence; state the missing data.115116Correlation, ranking, trend, anomaly, and composition detectors produce117descriptive candidates, not causal conclusions. Drill down through contribution,118segment, volume × rate/price, anomaly/data-quality, and stability/sample-size119checks when the data supports them.120121## Visual and table contract122123- Prefer position and length encodings over angle, area, volume, and decorative124 effects.125- A pie chart is limited to 2–3 positive categories and approximate share.126- Use a visible companion table for exact lookup, high-density comparison,127 exceptions, risk/action lists, or four-plus measures.128- Every chart still needs a default-hidden `查看数据` source table, chart-level129 statistical scope, data source, and evidence/query reference.130- Include units, readable labels, semantic colors, responsive sizing, and a131 text/table fallback. Do not rely on color alone.132- Do not invent a product, brand, industry label, or title that is absent from133 the request, governed scope, schema, and evidence.134- Mixed bar/line charts with different units or magnitudes require separate135 y-axes and explicit `yAxisIndex: 0` / `yAxisIndex: 1` assignment.136137## Standalone HTML and runtime contract138139- Inline ECharts and required local assets; no CDN, runtime loader, `fetch()` to140 external URLs, iframe/object/embed, self-navigation, or `file://` nesting.141- Load libraries before chart bootstrap. Use literal `</script>` closing tags.142- Serialize data with `json.dumps(..., ensure_ascii=False, default=str)`; never143 hand-write large JavaScript data objects or call `JSON.parse({...})`.144- Use real responsive chart dimensions and resize handling.145- Dashboard runtime rules cover map registration including accidental146 `chinaGeoJSON` references, PDF export compatibility including `color-mix()`,147 card/grid density, data-table controls, and export/download behavior.148149## Routing references150151| Request | Read |152|---|---|153| Import or cleaning | `workflow_specs/data_cleaning_workflow.md` |154| Chart selection | `workflow_specs/analysis_expression_quality.md`, `references/chart_capabilities.json` |155| Dashboard | `workflow_specs/dashboard_workflow.md`, `workflow_specs/dashboard_runtime_quality.md` |156| Report | `workflow_specs/report_workflow.md` |157| Domain analysis | `workflow_specs/expert_library/INDEX.md` |158| Domain dashboard | `workflow_specs/dashboard_expert_library/INDEX.md` |159| Individual commands or CLI detail | `commands/echart/*.md` |160161When adding a reusable dashboard expert, start from162`workflow_specs/dashboard_expert_library/DASHBOARD_EXPERT_TEMPLATE.md`; never163place a project-specific dashboard or query in the skill.164165## Release hygiene166167Run:168169```bash170bash package.sh171python scripts/validate_release_package.py dist/<package>.zip172```173174The package uses an allowlist. Project SQL, database connection files, outputs,175logs, caches, tests, and local indexes are forbidden release content.