@@ -500,6 +500,77 @@ describe('Chart', () => {
500500
501501 expect ( chart . data . data . length ) . toBe ( lengthBeforeMutation ) ;
502502 } ) ;
503+
504+ // AG-16389: updateDelta should not reset data accumulated via applyTransaction
505+ it ( 'should preserve applyTransaction data when updateDelta changes series options' , async ( ) => {
506+ const initialData = [
507+ { x : 0 , y : 10 } ,
508+ { x : 1 , y : 20 } ,
509+ ] ;
510+
511+ const options = prepareTestOptions < {
512+ data : { x : number ; y : number } [ ] ;
513+ series : any [ ] ;
514+ } > ( {
515+ data : initialData ,
516+ series : [
517+ {
518+ type : 'line' ,
519+ xKey : 'x' ,
520+ yKey : 'y' ,
521+ connectMissingData : false ,
522+ } ,
523+ ] ,
524+ } ) ;
525+
526+ // Step 1: Create chart with initial data
527+ const chartProxy = AgCharts . create ( options ) ;
528+ chart = deproxy ( chartProxy ) ;
529+ await waitForChartStability ( chart ) ;
530+ expect ( chart . data . data . length ) . toBe ( 2 ) ;
531+
532+ // Step 2: updateDelta with increasing length data-set (simulates loading data)
533+ await chartProxy . updateDelta ( {
534+ data : [
535+ { x : 0 , y : 10 } ,
536+ { x : 1 , y : 20 } ,
537+ { x : 2 , y : 30 } ,
538+ ] ,
539+ } ) ;
540+ await waitForChartStability ( chart ) ;
541+ expect ( chart . data . data . length ) . toBe ( 3 ) ;
542+
543+ // Step 3: Full update back to initialData (simulates user action that resets data)
544+ await chartProxy . updateDelta ( { data : initialData } ) ;
545+ await waitForChartStability ( chart ) ;
546+ expect ( chart . data . data . length ) . toBe ( 2 ) ;
547+
548+ // At this point, DataSet.data and userOptions.data may have different references
549+ // Step 4: Use applyTransaction to add more data (streaming scenario)
550+ await chartProxy . applyTransaction ( {
551+ add : [
552+ { x : 2 , y : 30 } ,
553+ { x : 3 , y : 40 } ,
554+ ] ,
555+ } ) ;
556+ await waitForChartStability ( chart ) ;
557+ expect ( chart . data . data . length ) . toBe ( 4 ) ;
558+
559+ // Step 5: Toggle series option - this should NOT reset the data
560+ await chartProxy . updateDelta ( {
561+ series : options . series . map ( ( s ) => ( { ...s , connectMissingData : true } ) ) ,
562+ } ) ;
563+ await waitForChartStability ( chart ) ;
564+
565+ // Data should still have 4 items (not reset to initial 2)
566+ expect ( chart . data . data . length ) . toBe ( 4 ) ;
567+ expect ( chart . data . data ) . toEqual ( [
568+ { x : 0 , y : 10 } ,
569+ { x : 1 , y : 20 } ,
570+ { x : 2 , y : 30 } ,
571+ { x : 3 , y : 40 } ,
572+ ] ) ;
573+ } ) ;
503574 } ) ;
504575
505576 describe ( 'Chart data inherited by Series' , ( ) => {
0 commit comments