gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.93k stars 639 forks source link

Pie chart with unexpected behavior #795

Open fabiowillian opened 4 years ago

fabiowillian commented 4 years ago

Category

Version

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

Expected / Desired Behavior / Question

I'm trying to create a pie chart like described on the documentation, using the following code:

   var dataChartPieStat = [
      {
        name  : 'Project Status',
        labels: ['Red', 'Amber', 'Green', 'Complete', 'Cancelled', 'Unknown'],
        values: [25, 5, 5, 5, 5, 5]
      }
    ];

    slideOne.addChart(pres.ChartType.pie, dataChartPieStat, {
      x: 0.3, y: 4, w: 4, h: 2.5, legendPos: 'left',
      legendFontFace: 'Courier New',
      showLegend: true,
      showLeaderLines: true,
      showPercent: false,
      title: 'CHARTS',
      showValue: true,
      chartColors: ['FC0000', 'FFCC00', '009900', '0088CC', '696969', '6600CC'],
      dataBorder: { pt: '2', color: 'F1F1F1' },
      dataLabelColor: 'FFFFFF',
      dataLabelFontSize: 14,
      dataLabelPosition: 'bestFit', // 'bestFit' | 'outEnd' | 'inEnd' | 'ctr'
    })

Observed Behavior

This is the chart that is being showed. Apparently the data set property 'name' is appearing on the place of 'labels'. Is that correct? It seems wrong.

image

ReimaFrgos commented 4 years ago

@fabiowillian I ran you code above exactly as is and it produced correctly:

image

fabiowillian commented 4 years ago

@ReimaFrgos which lib version are you using? It's weird...

ReimaFrgos commented 4 years ago

@fabiowillian used 3.2.1 through the JS Fiddle, as well as the latest 3.3.0 Beta locally

fabiowillian commented 4 years ago

@ReimaFrgos I found the problem 😄 I was opening the file on LibreOffice Impress. For any reason, the chart does not open correctly there. Using others .pptx viewers appeared correctly.

Tks!