Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pie chart explosion opt to charts #17

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

sam-pitch
Copy link

Adds the "explosion" prop to PptxGenJS. This will allow us to get something approximating our pie chart padding

@sam-pitch sam-pitch self-assigned this Oct 10, 2022
@linear
Copy link

linear bot commented Oct 10, 2022

SWI-221 Chart: Pie options

Unsupported options

  • padding
  • rounding

Other problems

  • No option to set the label position

@@ -1563,6 +1563,9 @@ function makeChartType(chartType: CHART_NAME, data: IOptsChartData[], opts: ICha
strXml += '<c:' + chartType + 'Chart>'
strXml += ' <c:varyColors val="1"/>'
strXml += '<c:ser>'
if (opts.chartPieExplosion) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to do a couple of safety checks before passing it to the xml i.e. is it a valid number?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the following fine?

if (opts.chartPieExplosion && Number.isInteger(opts.chartPieExplosion)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support floats? And is there a min or max limit? I've seen some PPTX errors before because the number were out of range.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and Explosion needs to be an integer value according to c-rex

I don't think we should be overly defensive here. The values which Pitch can produce are quite narrow (0 - 10).

@@ -1519,6 +1519,7 @@ export interface IChartPropsChartPie {
* @default 0
*/
firstSliceAng?: number
chartPieExplosion?: number
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this protect us from bad inputs without having to add manual inline checks? @tjinauyeung

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these definitions are not checked unfortunately. We're not using any of the TS definitions when using the library.

@sam-pitch sam-pitch merged commit 647b102 into pitch-main Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants