@@ -955,6 +955,7 @@ test('should apply dashed line style to time comparison series with single metri
955955 formData : {
956956 ...timeCompareFormData ,
957957 time_compare : [ '1 week ago' ] ,
958+ timeShiftColor : true ,
958959 comparison_type : ComparisonType . Values ,
959960 } ,
960961 queriesData : queriesDataWithTimeCompare ,
@@ -974,18 +975,9 @@ test('should apply dashed line style to time comparison series with single metri
974975 expect ( comparisonSeries ) . toBeDefined ( ) ;
975976 // Main series should not have a dash pattern array
976977 expect ( Array . isArray ( mainSeries ?. lineStyle ?. type ) ) . toBe ( false ) ;
977- // Comparison series should have a visible dash pattern array [dash, gap]
978- expect ( Array . isArray ( comparisonSeries ?. lineStyle ?. type ) ) . toBe ( true ) ;
979- expect (
980- Array . isArray ( comparisonSeries ?. lineStyle ?. type )
981- ? comparisonSeries . lineStyle . type [ 0 ]
982- : undefined ,
983- ) . toBeGreaterThanOrEqual ( 4 ) ;
984- expect (
985- Array . isArray ( comparisonSeries ?. lineStyle ?. type )
986- ? comparisonSeries . lineStyle . type [ 1 ]
987- : undefined ,
988- ) . toBeGreaterThanOrEqual ( 3 ) ;
978+ expect ( mainSeries ?. lineStyle ?. type ) . not . toBe ( 'dotted' ) ;
979+ // Comparison series should have a visible dash pattern
980+ expect ( comparisonSeries ?. lineStyle ?. type ) . toBe ( 'dotted' ) ;
989981} ) ;
990982
991983test ( 'should apply dashed line style to time comparison series with metric__offset pattern' , ( ) => {
@@ -1008,6 +1000,7 @@ test('should apply dashed line style to time comparison series with metric__offs
10081000 formData : {
10091001 ...timeCompareFormData ,
10101002 time_compare : [ '1 week ago' ] ,
1003+ timeShiftColor : true ,
10111004 comparison_type : ComparisonType . Values ,
10121005 } ,
10131006 queriesData : queriesDataWithTimeCompare ,
@@ -1029,18 +1022,8 @@ test('should apply dashed line style to time comparison series with metric__offs
10291022 expect ( comparisonSeries ) . toBeDefined ( ) ;
10301023 // Main series should not have a dash pattern array
10311024 expect ( Array . isArray ( mainSeries ?. lineStyle ?. type ) ) . toBe ( false ) ;
1032- // Comparison series should have a visible dash pattern array [dash, gap]
1033- expect ( Array . isArray ( comparisonSeries ?. lineStyle ?. type ) ) . toBe ( true ) ;
1034- expect (
1035- Array . isArray ( comparisonSeries ?. lineStyle ?. type )
1036- ? comparisonSeries . lineStyle . type [ 0 ]
1037- : undefined ,
1038- ) . toBeGreaterThanOrEqual ( 4 ) ;
1039- expect (
1040- Array . isArray ( comparisonSeries ?. lineStyle ?. type )
1041- ? comparisonSeries . lineStyle . type [ 1 ]
1042- : undefined ,
1043- ) . toBeGreaterThanOrEqual ( 3 ) ;
1025+ // Comparison series should have a visible dash pattern
1026+ expect ( comparisonSeries ?. lineStyle ?. type ) . toBe ( 'dotted' ) ;
10441027} ) ;
10451028
10461029test ( 'should apply connectNulls to time comparison series' , ( ) => {
@@ -1352,3 +1335,52 @@ test('should not apply axis bounds calculation when seriesType is not Bar for ho
13521335 // Should not have explicit max set when seriesType is not Bar
13531336 expect ( xAxisRaw . max ) . toBeUndefined ( ) ;
13541337} ) ;
1338+
1339+ test ( 'should assign distinct dash patterns for multiple time offsets consistently' , ( ) => {
1340+ const queriesDataWithMultipleOffsets = [
1341+ createTestQueryData ( [
1342+ {
1343+ sum__num : 100 ,
1344+ '1 year ago' : 80 ,
1345+ '2 years ago' : 60 ,
1346+ __timestamp : 599616000000 ,
1347+ } ,
1348+ {
1349+ sum__num : 150 ,
1350+ '1 year ago' : 120 ,
1351+ '2 years ago' : 90 ,
1352+ __timestamp : 599916000000 ,
1353+ } ,
1354+ ] ) ,
1355+ ] ;
1356+
1357+ const chartProps = createTestChartProps ( {
1358+ formData : {
1359+ ...timeCompareFormData ,
1360+ time_compare : [ '1 year ago' , '2 years ago' ] ,
1361+ comparison_type : ComparisonType . Values ,
1362+ timeShiftColor : true ,
1363+ } ,
1364+ queriesData : queriesDataWithMultipleOffsets ,
1365+ } ) ;
1366+
1367+ const transformed = transformProps ( chartProps ) ;
1368+ const series = ( transformed . echartOptions . series as SeriesOption [ ] ) || [ ] ;
1369+
1370+ const series1 = series . find ( s => s . name === '1 year ago' ) as any ;
1371+ const series2 = series . find ( s => s . name === '2 years ago' ) as any ;
1372+
1373+ expect ( series1 ) . toBeDefined ( ) ;
1374+ expect ( series2 ) . toBeDefined ( ) ;
1375+
1376+ const pattern1 = series1 . lineStyle ?. type ;
1377+ const symbol1 = series1 . symbol ;
1378+ const pattern2 = series2 . lineStyle ?. type ;
1379+ const symbol2 = series2 . symbol ;
1380+
1381+ // must be different patterns
1382+ expect ( pattern1 ) . not . toEqual ( pattern2 ) ;
1383+
1384+ // must be different patterns
1385+ expect ( symbol1 ) . not . toEqual ( symbol2 ) ;
1386+ } ) ;
0 commit comments