Charts: add scatter charts (chartType "scatter")

未关闭
#622 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

Start with _add_chart in sdpm/sdpm/engine/builder/elements/chart.py and the named chart round-trip tests in tests/test_chart_roundtrip.py; check how chart data and series colors are currently built. Then trace chart extraction in sdpm/sdpm/engine/converter/chart.py and scatter validation in sdpm/sdpm/engine/schema/lint.py. Done when the listed scatter round-trip, lint, and edit-rebuild cases pass, along with make lint and uv run pytest tests/test_chart_roundtrip.py -v.

由索引模型根据 Issue 内容生成。

描述

enhancement good first issue
What problem would this solve?

Native charts support chartType bar, line, pie and donut only, and all of them plot values against categories. A scatter chart plots two numeric variables against each other (latency vs. payload size, cost vs. throughput, before/after benchmarks), which a category chart cannot show. python-pptx builds scatter charts natively (XL_CHART_TYPE.XY_SCATTER with XyChartData). Today a chartType: "scatter" silently becomes a bar chart (see TestInvalidInput::test_unknown_chart_type_degrades_to_bar).

Proposed solution

Add chartType: "scatter". Its series carry points ([x, y] pairs) instead of values, and it takes no categories:

{
  "type": "chart", "chartType": "scatter",
  "x": 192, "y": 216, "width": 1536, "height": 700,
  "series": [
    {"name": "Lambda", "points": [[128, 45], [256, 30], [512, 22], [1024, 18]], "color": "#FF9900"},
    {"name": "Fargate", "points": [[128, 60], [512, 35], [1024, 25]], "color": "#41B3FF"}
  ],
  "legend": true,
  "valueAxis": {"min": 0},
  "title": "Latency (ms) by memory (MB)"
}
  • Markers only (XL_CHART_TYPE.XY_SCATTER); series color is the marker colour; style.markerSize applies. Connecting lines (XY_SCATTER_LINES*, XY_SCATTER_SMOOTH*) are out of scope for this issue.
  • valueAxis applies to the Y axis as it does today. X-axis options can come in a follow-up; keep the default X axis in this issue.

Files to touch:

  • sdpm/sdpm/engine/builder/elements/chart.py (_add_chart): build the data with XyChartData (add_series(name) then series.add_data_point(x, y)) when chartType is scatter, add it to the type_map, and colour the series markers. The current code always builds CategoryChartData and generates placeholder categories, so this is the main change.
  • sdpm/sdpm/engine/converter/chart.py (extract_chart_element): map XY_SCATTER in type_map and read each series' points. python-pptx's series.values gives the Y values only; read X from the series' c:xVal element. Write points, not categories / values.
  • sdpm/sdpm/engine/schema/lint.py: add scatter to _CHART_TYPES, update the "Specify bar, line, pie, or donut" message, skip the categories/values length check for scatter, and flag a scatter series without points.
  • Docs: the chart section of sdpm/references/guides/slide-json-media.md (chartType list, the points shape, guide list), and a new sdpm/references/guides/chart-scatter.md modelled on chart-line.md. If you add the guide, also add it next to chart-bar / chart-line / chart-pie in sdpm/references/guides/slide-json-spec.md and sdpm/references/workflows/composer.md.
  • CHANGELOG.md: an entry under [Unreleased] → Added.

Done when

  • chartType: "scatter" builds a c:scatterChart, and pptx_to_json reads it back as chartType: "scatter" with series names, points (in order) and colours intact.
  • An edited scatter chart (a changed point) is rebuilt from its JSON, not restored from _chartXml.
  • TestInvalidInput::test_unknown_chart_type_degrades_to_bar uses another unknown type name instead of scatter.
  • Lint accepts scatter and still rejects unknown types.
  • make lint and uv run pytest tests/test_chart_roundtrip.py -v pass.

Tests to copy: TestChartTypes::test_line_markers, TestSeriesAndCategories::test_non_ascii_and_float_values and TestColors::test_line_series_color in tests/test_chart_roundtrip.py (they use _one_chart / _built_chart, no LibreOffice needed).

Which area?

Slide generation / engine (layouts, elements, charts)

🤖 Created by Kiro Crew

主要语言
Python
星标
136
派生
13
平均合并
7 小时 36 分钟
30 天内合并 PR
175

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws-samples/sample-spec-driven-presentation-maker 的其他 Issue

查看 aws-samples/sample-spec-driven-presentation-maker 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。