Skip to content
New issue

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

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

Already on GitHub? # to your account

dataLabelFormatCode option creates corrupted file if the value includes quotes #834

Closed
kornarakis opened this issue Aug 27, 2020 · 3 comments · Fixed by #884
Closed

dataLabelFormatCode option creates corrupted file if the value includes quotes #834

kornarakis opened this issue Aug 27, 2020 · 3 comments · Fixed by #884

Comments

@kornarakis
Copy link

kornarakis commented Aug 27, 2020

Category

Bug

Version

Please specify what version of the library you are using: [ 3.3.1 ]

Please specify what version(s) of PowerPoint you are targeting: [ 365 ]

Expected / Desired Behavior / Question

On Bar chart type when using the dataLabelFormatCode with a value like #,##0.0"%" the generated pptx file is corrupted.

Observed Behavior

My demo numbers are

value
A 15.5
B 20.32

The expected behavior is to show the numbers on the bar charts as 15.5% and 20.3%. The format code #,##0.0"%" is working fine if you set it in Powerpoint directly.

Steps to Reproduce

Create a bar chart with the following code

 let testdata = [{
    name: '',
    labels: ['A', 'B'],
    values: [15.5,20.32 ],
  }]
 slide.addChart(pptx.ChartType.bar, testdata, {
        catAxisLabelFontSize: 15,
        catAxisLabelColor: '75D4D6',
        catAxisLabelFontBold: true,
        catAxisLineShow: false,
        valAxisLineShow: false,
        valAxisHidden: true,
        lineSize: 4,
        barGapWidthPct: 50,
        dataLabelPosition: 'ctr',
        dataLabelFontSize: 10,
        dataLabelColor: '000000',
        dataLabelFormatCode: '#,##0.0"%"',
        showValue: true,
        showTitle : false,
        valGridLine: { style: 'none' },
        catGridLine: { style: 'none' },
        x: 1.81,
        y: 2.51,
        w: 1.94,
        h: 1.73,
      })
@galzo
Copy link

galzo commented Jan 13, 2021

According to official Microsoft documentation, you can add symbols and characters by wrapping them with "".
another option is to use an escaping character. so in your case you should use: \%
escaping seems to be working on PptxGenJS, but "" seems to corrupt the file.

I'll try to fix this issue.

@galzo
Copy link

galzo commented Jan 13, 2021

Issue Fixed. I'll send a PR now.

@gitbrent
Copy link
Owner

Thanks for reporting this @kornarakis

Fixed thanks to @galzo

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants