Repository navigation
Add L.chart and LChart for bar charts - #82
Merged
Merged
Conversation
L.chart builds a chart, and LChart.series, LChart.category and LChart.value its parts. LChart.value takes an int, a float or a str, and writes a float in full, without an exponent. Work: 686
The SDK keeps one class per file, as the markdown's nodes have, and the four chart nodes were in one. A whole float past 2**53 was written from its binary value, so 1e23 became 99999999999999991611392 in the XML `L.to_xml` writes, where the other SDKs write 100000000000000000000000. The PDF was the same, since the engine reads both as the same float. Work: 686
Python often holds money as a Decimal, which LChart.value refused, and str() of one can write an exponent the engine refuses (1E+3). Work: 686
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andLChart.series,LChart.categoryandLChart.valueits parts, with their nodes.LChart.value(NoAttr, [41200])takes ints, floats,Decimals and strs. A float is written from its shortest digits (repr) in full, without an exponent, and a whole float without its.0, as the other SDKs write it:1e23is100000000000000000000000. ADecimalkeeps its decimals (0.250) and is written without an exponent (1E+3is1000). Aboolis aTypeError, and a float or aDecimalthat is not finite aValueError.ChartNode,ChartSeriesNode,ChartCategoryNodeandChartValueNodeeach have their own, as the markdown's nodes do.ChartAttr,ChartSeriesAttrandChartCategoryAttr, and the constantsChartType,ChartDirectionandChartLegend, generated from the schema (make gen-sdk-api).How it was checked
make test-sdk-python: 265 pass, with tests for the nodes, the numbers, the PDF of a chart built in code against the PDF of its XML, and a category with the wrong count of values.make check-codegen-sdk-pythonagainst 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.Work: 686