Skip to content

Add L.chart and LChart for bar charts - #23

Merged
codesensedev merged 2 commits into
mainfrom
686-bar-charts
Nov 25, 2026
Merged

codesensedev merged 2 commits into
mainfrom
686-bar-charts

Conversation

@codesensedev

@codesensedev codesensedev commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Core adds a <chart> element with bar charts (lpdfio/lpdf#195). This adds its builders, so a chart can be built in code as in XML.

What changes

  • L.chart(ChartAttr, parts) builds a chart, and LChart.series, LChart.category and LChart.value its parts, with their nodes. L.chart takes no NoAttr, as type and height are required.
  • LChart.value(NoAttr, List.of(41200)) takes an Integer, a Long, a Short, a Byte, a BigInteger, a BigDecimal, a Double, a Float or a String, and LChart.value(NoAttr) is no value. A double is written through BigDecimal in full, without the exponent Double.toString writes for 1.2345678E7, and a whole double without its .0; a BigDecimal keeps its scale.
  • ChartAttr, ChartSeriesAttr and ChartCategoryAttr, and the constants ChartType, ChartDirection and ChartLegend, generated from the schema (make gen-sdk-api).

How it was checked

  • mvn test: 258 pass, with tests for the nodes, the numbers, a float written from its own digits, the PDF of a chart built in code against the PDF of its XML, and a category with the wrong count of values. NoAttributesTest covers LChart.
  • make check-codegen-sdk-java against the engine and schema of core's branch: 1047 of 1047 documents render the PDF of their XML, the chart fixtures and corpus documents among them.
  • This repository's CI builds against the last core release, which has no chart, so it fails until a release candidate carries core's change.

Work: 686

L.chart builds a chart, and LChart.series, LChart.category and
LChart.value its parts. LChart.value takes a Number or a String, and
writes a double in full, without an exponent.

Work: 686
Nothing kept the Float branch of LChart.value: through doubleValue(),
0.1f would be written 0.10000000149011612, which a value label shows.

Work: 686
@codesensedev
codesensedev merged commit e2a973f into main Nov 25, 2026
3 of 6 checks passed
@codesensedev
codesensedev deleted the 686-bar-charts branch November 25, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant