@@ -45,11 +45,15 @@ export class ModifyChart {
4545 this . width = this . columns . length ;
4646 }
4747
48- modify ( ) {
48+ modify ( ) : void {
4949 this . setValues ( ) ;
5050 this . setSeries ( ) ;
51+ this . sliceChartSpace ( ) ;
52+
5153 this . setWorkbook ( ) ;
54+ this . sliceWorkbook ( ) ;
5255 this . setWorkbookTable ( ) ;
56+ this . sliceWorkbookTable ( ) ;
5357 }
5458
5559 setColumns ( slot : ChartSlot [ ] ) : ChartColumn [ ] {
@@ -62,9 +66,10 @@ export class ModifyChart {
6266
6367 const label = slot . label ? slot . label : series . label ;
6468
65- const mapData = slot . mapData ? slot . mapData : ( point : number ) => point ;
69+ const mapData =
70+ slot . mapData !== undefined ? slot . mapData : ( point : number ) => point ;
6671
67- const isStrRef = slot . isStrRef ? slot . isStrRef : true ;
72+ const isStrRef = slot . isStrRef !== undefined ? slot . isStrRef : true ;
6873
6974 const worksheetCb = (
7075 point : number ,
@@ -115,23 +120,22 @@ export class ModifyChart {
115120 this . columns
116121 . filter ( ( col ) => col . chart )
117122 . forEach ( ( col ) => {
118- if ( category . values [ col . series ] === undefined ) {
119- throw new Error ( `No value for category "${ category . label } " at series "${ ( col . label ) } ".` )
123+ if ( category . values [ col . series ] === undefined ) {
124+ throw new Error (
125+ `No value for category "${ category . label } " at series "${ col . label } ".` ,
126+ ) ;
120127 }
121128
122- this . chart . modify (
123- this . series (
124- col . series ,
125- col . chart ( category . values [ col . series ] , c , category ) ,
126- ) ,
127- ) ;
129+ col . modTags = col . chart ( category . values [ col . series ] , c , category ) ;
130+
131+ this . chart . modify ( this . series ( col . series , col . modTags ) ) ;
128132 } ) ;
129133 } ) ;
130134 }
131135
132136 setSeries ( ) : void {
133137 this . columns . forEach ( ( column , colId ) => {
134- if ( column . isStrRef === undefined || column . isStrRef === true ) {
138+ if ( column . isStrRef === true ) {
135139 this . chart . modify (
136140 this . series ( column . series , {
137141 ...this . seriesId ( column . series ) ,
@@ -142,6 +146,23 @@ export class ModifyChart {
142146 } ) ;
143147 }
144148
149+ sliceChartSpace ( ) : void {
150+ this . chart . modify ( {
151+ 'c:plotArea' : this . slice ( 'c:ser' , this . data . series . length ) ,
152+ } ) ;
153+
154+ this . columns
155+ . filter ( ( column ) => column . modTags )
156+ . forEach ( ( column ) => {
157+ const sliceMod = { } ;
158+
159+ Object . keys ( column . modTags ) . forEach ( ( tag ) => {
160+ sliceMod [ tag ] = this . slice ( 'c:pt' , this . height ) ;
161+ } ) ;
162+ this . chart . modify ( this . series ( column . series , sliceMod ) ) ;
163+ } ) ;
164+ }
165+
145166 setWorkbook ( ) : void {
146167 this . workbook . modify ( this . spanString ( ) ) ;
147168 this . workbook . modify ( this . rowAttributes ( 0 , 1 ) ) ;
@@ -161,6 +182,28 @@ export class ModifyChart {
161182 } ) ;
162183 }
163184
185+ sliceWorkbook ( ) : void {
186+ this . data . categories . forEach ( ( category , c ) => {
187+ const r = c + 1 ;
188+ this . workbook . modify ( {
189+ row : {
190+ index : r ,
191+ ...this . slice ( 'c' , this . width + 1 ) ,
192+ } ,
193+ } ) ;
194+ } ) ;
195+
196+ this . workbook . modify ( {
197+ row : {
198+ ...this . slice ( 'c' , this . width + 1 ) ,
199+ } ,
200+ } ) ;
201+
202+ this . workbook . modify ( {
203+ sheetData : this . slice ( 'row' , this . height + 1 ) ,
204+ } ) ;
205+ }
206+
164207 series = ( index : number , children : ModificationTags ) : ModificationTags => {
165208 return {
166209 'c:ser' : {
@@ -311,6 +354,18 @@ export class ModifyChart {
311354 } ;
312355 }
313356
357+ slice ( tag : string , length : number ) : Modification {
358+ return {
359+ children : {
360+ [ tag ] : {
361+ collection : ( collection : HTMLCollectionOf < Element > ) => {
362+ XmlHelper . sliceCollection ( collection , length ) ;
363+ } ,
364+ } ,
365+ } ,
366+ } ;
367+ }
368+
314369 spanString ( ) : ModificationTags {
315370 return {
316371 dimension : {
@@ -365,4 +420,10 @@ export class ModifyChart {
365420 } ,
366421 } ) ;
367422 }
423+
424+ sliceWorkbookTable ( ) : void {
425+ this . workbookTable . modify ( {
426+ table : this . slice ( 'tableColumn' , this . width + 1 ) ,
427+ } ) ;
428+ }
368429}
0 commit comments