Skip to content

Commit bea6755

Browse files
committed
chore(chart): modify chart point border
1 parent acdc722 commit bea6755

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

src/helper/modify-color-helper.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export default class ModifyColorHelper {
88
* Replaces or creates an <a:solidFill> Element
99
*/
1010
static solidFill = (color: Color, index?:number|'last') => (element: Element): void => {
11+
if(!color?.type) return
12+
1113
const solidFills = element.getElementsByTagName('a:solidFill')
1214

1315
if(!solidFills.length) {
@@ -31,5 +33,13 @@ export default class ModifyColorHelper {
3133

3234
XmlHelper.sliceCollection(solidFill.childNodes as unknown as HTMLCollectionOf<Element>, 0)
3335
solidFill.appendChild(colorType)
36+
37+
}
38+
39+
static removeNoFill = () => (element: Element): void => {
40+
const hasNoFill = element.getElementsByTagName('a:noFill')[0]
41+
if(hasNoFill) {
42+
element.removeChild(hasNoFill)
43+
}
3444
}
3545
}

src/modify/modify-chart.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ChartDataMapper,
99
ChartSeries, ChartValueStyle,
1010
} from '../types/chart-types';
11-
import {ModificationTags, Modification, Color} from '../types/modify-types';
11+
import {ModificationTags, Modification, Color, ModifyCallback} from '../types/modify-types';
1212
import { XmlHelper } from '../helper/xml-helper';
1313
import CellIdHelper from '../helper/cell-id-helper';
1414
import { Workbook } from '../types/types';
@@ -289,9 +289,10 @@ export class ModifyChart {
289289
modify: ModifyXmlHelper.attribute('val', idx)
290290
},
291291
'c:spPr': {
292-
modify: ModifyColorHelper.solidFill(style.color),
292+
modify: ModifyColorHelper.solidFill(style?.color),
293293
},
294-
...this.chartPointMarker(style.marker)
294+
...this.chartPointBorder(style?.border),
295+
...this.chartPointMarker(style?.marker)
295296
}
296297
}
297298
}
@@ -311,6 +312,24 @@ export class ModifyChart {
311312
}
312313
}
313314
}
315+
chartPointBorder = (style: ChartValueStyle['border']): ModificationTags => {
316+
if(!style) return
317+
const modify = <ModifyCallback[]>[]
318+
319+
if(style.color) {
320+
modify.push(ModifyColorHelper.solidFill(style.color))
321+
modify.push(ModifyColorHelper.removeNoFill())
322+
}
323+
if(style.weight) {
324+
modify.push(ModifyXmlHelper.attribute('w', style.weight))
325+
}
326+
327+
return {
328+
'a:ln': {
329+
modify: modify
330+
}
331+
}
332+
}
314333

315334
seriesId = (series: number): ModificationTags => {
316335
return {

src/types/chart-types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ export type ChartValueStyle = {
55
color?: Color;
66
marker?: {
77
color?: Color;
8-
}
8+
};
9+
border?: {
10+
color?: Color;
11+
weight?: number;
12+
};
913
label?: {
1014
color?: Color;
1115
isBold?: Boolean

0 commit comments

Comments
 (0)