Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/gen-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,19 @@ function makeChartType (chartType: CHART_NAME, data: IOptsChartData[], opts: ICh
obj.labels[0].forEach((label, idx) => (strXml += `<c:pt idx="${idx}"><c:v>${encodeXmlEntities(label)}</c:v></c:pt>`))
strXml += ' </c:numCache>'
strXml += ' </c:numRef>'
} else if (obj.labels.length === 1) {
// Single-level string categories: emit the idiomatic single-level `c:strRef`
// (same form used by the pie/doughnut chart types below). A `c:multiLvlStrRef`
// with a single level is valid but non-idiomatic: PowerPoint tolerates it, but
// Google Slides / LibreOffice mis-render the category axis and strict parsers
// (e.g. pptxtojson) fail to read the labels.
strXml += ' <c:strRef>'
strXml += ` <c:f>Sheet1!$A$2:$A$${obj.labels[0].length + 1}</c:f>`
strXml += ' <c:strCache>'
strXml += ` <c:ptCount val="${obj.labels[0].length}"/>`
obj.labels[0].forEach((label, idx) => (strXml += `<c:pt idx="${idx}"><c:v>${encodeXmlEntities(label)}</c:v></c:pt>`))
strXml += ' </c:strCache>'
strXml += ' </c:strRef>'
} else {
strXml += ' <c:multiLvlStrRef>'
strXml += ` <c:f>Sheet1!$A$2:$${getExcelColName(obj.labels.length)}$${obj.labels[0].length + 1}</c:f>`
Expand Down
7 changes: 6 additions & 1 deletion src/gen-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,12 @@ function slideObjectRelationsToXml (slide: PresSlide | SlideLayout, defaultRels:
})
; (slide._relsChart || []).forEach((rel: ISlideRelChart) => {
lastRid = Math.max(lastRid, rel.rId)
strXml += `<Relationship Id="rId${rel.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" Target="${rel.Target}"/>`
// Relationship targets are relative to the slide part, e.g. "../charts/chartN.xml" (what
// PowerPoint writes). The stored `rel.Target` is the absolute "/ppt/charts/chartN.xml" form,
// which is reused verbatim as the absolute Content_Types PartName. Absolute relationship
// targets are valid but non-idiomatic and are mishandled by stricter consumers (e.g.
// pptxtojson resolves them to an invalid path and drops the chart), so relativize here only.
strXml += `<Relationship Id="rId${rel.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" Target="${rel.Target.replace(/^\/ppt\//, '../')}"/>`
})
; (slide._relsMedia || []).forEach((rel: ISlideRelMedia) => {
const relRid = rel.rId.toString()
Expand Down