Skip to content

Conversation

@666haiwen
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

visible: true,
style: {},
state: {
selected: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

状态可以考虑一下,是不是要统一到 inBrushoutOfBrush

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds brush (selection) functionality for pivot charts in the vseed library. The main purpose is to enable users to brush/select data in charts with configurable brush types (rect, polygon, x, y), brush modes (single, multiple), and custom styling for selected and unselected data.

Key changes include:

  • Added new brush configuration properties (brushType, brushMode, inBrushStyle, outOfBrushStyle) to the brush type definitions
  • Applied brush state styling (selected/selected_reverse) across 11 different chart mark types (bar, area, line, point, pie, rose, funnel, cell, boxPlot, outlier, funnelTransform)
  • Updated the @visactor/vtable dependency from version 1.22.9-alpha.2 to 1.22.10-alpha.0
  • Added a demo example in the documentation showing brush functionality with pivot charts

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pnpm-lock.yaml Updated @visactor/vtable dependency and related package versions to 1.22.10-alpha.0
packages/vseed/src/types/properties/brush/zBrush.ts Refactored brush type definitions, extracted common style config, added brushType and brushMode properties
packages/vseed/src/types/properties/brush/brush.ts Added comprehensive documentation for brush types, modes, and styling options
packages/vseed/src/pipeline/spec/chart/pipes/brush/brush.ts Added brushType and brushMode configuration to the brush spec generation
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/roseStyle.ts Added brush state styling (selected/selected_reverse) for rose charts
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/pointStyle.ts Added brush state styling for point marks
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/pieStyle.ts Added brush state styling for pie charts with proper state merging
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/outlierStyle.ts Added brush state styling for boxplot outlier marks
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/lineStyle.ts Added brush state styling for line marks
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/funnelTransformStyle.ts Added brush state styling for funnel transform elements
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/funnelStyle.ts Added brush state styling for funnel charts
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/cellStyle.ts Added brush state styling for cell/heatmap charts
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/boxPlotStyle.ts Added brush state styling for boxplot marks
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/barStyle.ts Added brush state styling for bar charts
packages/vseed/src/pipeline/spec/chart/pipes/markStyle/areaStyle.ts Added brush state styling for area charts
apps/website/package.json Updated @visactor/vtable dependency version
apps/website/docs/zh-CN/playground/vseed.mdx Added demo example showing brush functionality with pivot charts
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to +18
const isPivot = isPivotChart(vseed)

// 在pivot场景下读取brush配置
const brushConfig = isPivot ? ((advancedVSeed.config as any)?.[chartType]?.brush ?? ({} as BrushConfig)) : null
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brush configuration retrieval logic is duplicated across 11 mark style files. Consider extracting this into a shared utility function to reduce code duplication and improve maintainability. For example, create a helper function like getBrushConfig(isPivot, config, chartType) that returns the brush configuration.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +42
selected: {
opacity: brushConfig?.inBrushStyle?.opacity ?? 1,
...(brushConfig?.inBrushStyle?.stroke && { stroke: brushConfig.inBrushStyle.stroke }),
...(brushConfig?.inBrushStyle?.lineWidth && { lineWidth: brushConfig.inBrushStyle.lineWidth }),
},
selected_reverse: {
// fill: '#ddd'
opacity: brushConfig?.outOfBrushStyle?.opacity ?? 0.2,
...(brushConfig?.outOfBrushStyle?.stroke && { stroke: brushConfig.outOfBrushStyle.stroke }),
...(brushConfig?.outOfBrushStyle?.lineWidth && { lineWidth: brushConfig.outOfBrushStyle.lineWidth }),
},
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brush state configuration (selected and selected_reverse) is duplicated across 11 mark style files with identical logic. Consider extracting this into a shared utility function like getBrushStateConfig(brushConfig) that returns the state object. This would reduce code duplication and make it easier to maintain consistent brush behavior across all chart types.

Copilot uses AI. Check for mistakes.
* @default 'rect'
*/
brushType?: 'x' | 'y' | 'rect' | 'polygon'
/** 框选模式,单选还是多选,默认单选 */
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brushMode property lacks detailed documentation. Consider adding a description similar to brushType that explains what "single" and "multiple" modes do. For example: @description 定义刷选的模式 - 'single': 单选模式,每次只能有一个刷选框 - 'multiple': 多选模式,可以同时存在多个刷选框

Suggested change
/** 框选模式,单选还是多选,默认单选 */
/**
* 框选模式,单选还是多选
* @description 定义刷选的模式
* - `single`: 单选模式,每次只能有一个刷选框
* - `multiple`: 多选模式,可以同时存在多个刷选框
* @default 'single'
*/

Copilot uses AI. Check for mistakes.

result.brush = {
visible: true,
removeOnClick: brush.removeOnClick,
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removeOnClick property only uses the value from brush.removeOnClick without falling back to the theme configuration like brushMode and brushType do. Consider using a similar fallback pattern: removeOnClick: brush.removeOnClick ?? theme.removeOnClick to maintain consistency with other properties.

Suggested change
removeOnClick: brush.removeOnClick,
removeOnClick: brush.removeOnClick ?? theme.removeOnClick,

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +99
console.log('brush,!!!!!', datum.__MeaName__, datum)
return selectedDimValueRef.current.length ? selectedDimValueRef.current.includes(datum['__Dim_X__']) : true
},
selectedReverseStateFilter: (datum) => {
console.log('brush,????', datum)
return selectedDimValueRef.current.length ? !selectedDimValueRef.current.includes(datum['__Dim_X__']) : false
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.log statements should be removed before merging to production. These debug logs are left in the code and will clutter the browser console in production.

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +122
tableInstance.onVChartEvent('brushEnd', (args) => {
console.log('brushEnd', args)
selectedDimValueRef.current = args.value.inBrushData.map((dataItem) => dataItem.__Dim_X__)
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.log statements should be removed before merging to production. These debug logs are left in the code and will clutter the browser console in production.

Copilot uses AI. Check for mistakes.
Comment on lines +103 to 104
console.log('final spec = ', spec)
console.log('builder', builder)
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.log statements should be removed before merging to production. These debug logs are left in the code and will clutter the browser console in production.

Copilot uses AI. Check for mistakes.
...(brushConfig?.inBrushStyle?.lineWidth && { lineWidth: brushConfig.inBrushStyle.lineWidth }),
},
selected_reverse: {
// fill: '#ddd'
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed. If this was intended for debugging or testing purposes, it should be deleted before merging.

Suggested change
// fill: '#ddd'

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants