feat: vbi encoding fixes, measure builder improvements, and professional demo function extensions#333
feat: vbi encoding fixes, measure builder improvements, and professional demo function extensions#333LoganLCX wants to merge 1 commit intoVisActor:feat/vbifrom
Conversation
…nal app enhancements
| } | ||
|
|
||
| this.dsl.get('dimensions').push([yMap]) | ||
| const dimensionsArray = this.dsl.get('dimensions') as Y.Array<any> |
| dimensionYMap.set('encoding', encoding) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
建议实现一个 modifyDimension, 然后基于它, 实现modifyEncoding.
另外取名的话, update和modify需要选择一个统一的, 我建议modify, 因为我们的修改大多都是局部的.
| } | ||
| } | ||
|
|
||
| renameMeasure(measureAlias: string, newAlias: string) { |
There was a problem hiding this comment.
同上, 先实现modifyMeasure, 然后再rename功能
| } | ||
| } | ||
|
|
||
| updateAggregate(measureAlias: string, func: string) { |
There was a problem hiding this comment.
同上, 基于modifyMeasure, 来实现modifyAggregate
| } | ||
| } | ||
|
|
||
| updateEncoding(measureAlias: string, encoding: string) { |
|
|
||
| static isMeasureNode(node: VBIMeasureTree[0]): node is VBIMeasure { | ||
| return 'field' in node | ||
| return 'expr' in node |
| } | ||
|
|
||
| // 辅助函数:将 VBIMeasureTree 展开为平面的 VBIMeasure 数组 | ||
| private flattenMeasureTree(tree?: VBIMeasureTree): VBIMeasure[] { |
There was a problem hiding this comment.
共建函数可以放在这里, packages/vbi/src/utils/tree/traverse.ts
这类函数和业务完全无关, 不应放在builder内, 可以单独抽出来作为工具函数, 用更通用的形式来实现.
| } | ||
|
|
||
| // 辅助函数:将 VBIDimensionTree 展开为平面的 VBIDimension 数组 | ||
| private flattenDimensionTree(tree?: VBIDimensionTree): VBIDimension[] { |
| const queryResult = await connector.query({ queryDSL, schema, connectorId }) | ||
|
|
||
| // 转换 VBI measures 为 VSeed measures 格式 | ||
| const flatMeasures = this.flattenMeasureTree(vbiDSL.measures) |
There was a problem hiding this comment.
buildVSeed越来越大了, 我强烈建议抽出一个公共方法, builder内仅描述逻辑即可,
| // Always create Y.Array for measures, converting plain arrays if needed | ||
| const measuresArray = new Y.Array<any>() | ||
| if (vbi.measures && Array.isArray(vbi.measures) && vbi.measures.length > 0) { | ||
| for (const m of vbi.measures) { |
There was a problem hiding this comment.
我当时写的逻辑, 是业务yjs内部就会自动设置, 可以省去很多递归, 难道不是这样的?
| export const zVBIDimensionSchema = z.object({ | ||
| field: z.string(), | ||
| alias: z.string(), | ||
| encoding: z.string().optional(), |
There was a problem hiding this comment.
vseed有具体的encoding值, 不应只写一个string
| const measureSelects: Select<Record<string, unknown>> = measureNodes.map((measure) => { | ||
| return { | ||
| field: measure.field, | ||
| const field = exprField(measure.expr) |
There was a problem hiding this comment.
不太理解这个expr的具体作用, 具体有啥用? 是要支持用户自定义表达式?
| * 当前版本:仅支持字段引用 | ||
| * 未来版本:可扩展支持 if/case/cast 等表达式 | ||
| */ | ||
| export const zMeasureExpr = z.discriminatedUnion('type', [ |
There was a problem hiding this comment.
我懂了, 自定义表达式, 这个功能对目前而言, 太高级了, 我建议先暂时下掉, 这个功能需要在vquery内先实现.
vbi:add feat:基于离散字段新增指标&encoding逻辑&修改聚合方式&重命名&图表类型带encoding切换初步
professional:增加拖拽、重命名、修改聚合等,适配vbi新功能