From 1c3addb5f1da4709194137cafba7466fa77003d1 Mon Sep 17 00:00:00 2001 From: adityajai119 Date: Sun, 8 Nov 2026 15:14:46 +0530 Subject: [PATCH] fix(dataset): print transform result with inherited header and dimensions. close #15557 Generated-by: Claude Opus 5.5 via OpenCode --- src/data/helper/transform.ts | 36 +++++++++++++------------ test/ut/spec/data/dataTransform.test.ts | 25 +++++++++++++++++ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/data/helper/transform.ts b/src/data/helper/transform.ts index 62bcea0b2d..95209ae489 100644 --- a/src/data/helper/transform.ts +++ b/src/data/helper/transform.ts @@ -431,23 +431,7 @@ function applySingleDataTransform( }) ); - if (__DEV__) { - if (transOption.print) { - const printStrArr = map(resultList, extSource => { - const pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : ''; - return [ - '=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', - '- transform result data:', - makePrintable(extSource.data), - '- transform result dimensions:', - makePrintable(extSource.dimensions) - ].join('\n'); - }).join('\n'); - log(printStrArr); - } - } - - return map(resultList, function (result, resultIndex) { + const resultSourceList = map(resultList, function (result, resultIndex) { let errMsg = ''; if (!isObject(result)) { @@ -536,6 +520,24 @@ function applySingleDataTransform( null ); }); + + if (__DEV__) { + if (transOption.print) { + const printStrArr = map(resultSourceList, source => { + const pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : ''; + return [ + '=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', + '- transform result data:', + makePrintable(source.data), + '- transform result dimensions:', + makePrintable(map(source.dimensionsDefine, dimDef => dimDef.name)) + ].join('\n'); + }).join('\n'); + log(printStrArr); + } + } + + return resultSourceList; } function isSupportedSourceFormat(sourceFormat: SourceFormat): boolean { diff --git a/test/ut/spec/data/dataTransform.test.ts b/test/ut/spec/data/dataTransform.test.ts index 04cc20eae3..7cb9f5fed3 100644 --- a/test/ut/spec/data/dataTransform.test.ts +++ b/test/ut/spec/data/dataTransform.test.ts @@ -180,6 +180,31 @@ describe('dataTransform', function () { }); }); + it('print_inherited_header_and_dimensions', function () { + const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); + try { + const option: EChartsOption = { + dataset: [{ + source: makeDatasetSourceDetection() + }, { + transform: { type: 'filter', config: { dimension: 'product', ne: 'BBB' }, print: true } + }], + xAxis: { type: 'category' }, + yAxis: {}, + series: { type: 'bar', datasetIndex: 1 } + }; + + chart.setOption(option); + const printed = logSpy.mock.calls.map(args => args.join(' ')).join('\n'); + const header = JSON.stringify(['product', '2012', '2013', '2014', '2015']); + expect(printed).toContain('- transform result data:\n[' + header + ','); + expect(printed).toContain('- transform result dimensions:\n' + header); + } + finally { + logSpy.mockRestore(); + } + }); + });