Skip to content

Commit f4ec662

Browse files
committed
chore(chart): read chart type; #140
1 parent 841b33c commit f4ec662

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

__tests__/read-chart-info.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Automizer, { read } from '../src/index';
1+
import Automizer, { read, XmlHelper } from '../src/index';
22
import { vd } from '../src/helper/general-helper';
33

44
test('read chart info from workbook, e.g. series color', async () => {
@@ -17,7 +17,13 @@ test('read chart info from workbook, e.g. series color', async () => {
1717

1818
await pres
1919
.addSlide('charts', 1, (slide) => {
20-
slide.modifyElement('BarsStacked', [read.readChartInfo(info)]);
20+
slide.modifyElement('BarsStacked', [
21+
(ele, chart, workbook) => {
22+
// enable next line to log chart xml to console:
23+
// XmlHelper.dump(chart)
24+
},
25+
read.readChartInfo(info),
26+
]);
2127
})
2228
.write(`read-chart-info.test.pptx`);
2329

src/helper/modify-chart-helper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ export default class ModifyChartHelper {
281281
colorValue: colorElement.getAttribute('val'),
282282
});
283283
});
284+
285+
const chartTagName = series.item(0).parentNode.nodeName;
286+
info.chartType = chartTagName?.split(':')[1];
284287
};
285288

286289
/**

0 commit comments

Comments
 (0)