Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/export-cell-disable-backgro…
Browse files Browse the repository at this point in the history
…und' into fix/fs-style-align
  • Loading branch information
Rui-Sun committed May 20, 2024
2 parents 2eb064e + f4a7763 commit 35580da
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ $ rush docs

# 🤝 Contribution

If you would like to contribute, please read the [Code of Conduct ](./CODE_OF_CONDUCT.md) and [ Guide](./CONTRIBUTING.zh-CN.md) first。
If you would like to contribute, please read the [Code of Conduct ](./CODE_OF_CONDUCT.md) and [ Guide](./CONTRIBUTING.md) first。

Small streams converge to make great rivers and seas!

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: add disableBackground & disableBorder in exportCellImg() #1733",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
2 changes: 1 addition & 1 deletion docs/assets/api/en/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ Export a cell picture
* Export a cell picture
* @returns base64 picture
*/
exportCellImg(col: number, row: number): string
exportCellImg(col: number, row: number, options?: { disableBackground?: boolean; disableBorder?: boolean }): string
```

## exportCellRangeImg(Function)
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/api/zh/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ use case: 点击图例项后 更新过滤规则 来更新图表
* 导出某个单元格图片
* @returns base64图片
*/
exportCellImg(col: number, row: number): string
exportCellImg(col: number, row: number, options?: { disableBackground?: boolean; disableBorder?: boolean }): string
```

## exportCellRangeImg(Function)
Expand Down
27 changes: 27 additions & 0 deletions docs/assets/changelog/en/release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# v0.25.6

2024-05-17


**🆕 New feature**

- **@visactor/vtable**: add selected_clear event [#1705](https://github.com/VisActor/VTable/issues/1705)
- **@visactor/vtable**: add mergeCellInfo arg in event [#1667](https://github.com/VisActor/VTable/issues/1667)

**🐛 Bug fix**

- **@visactor/vtable**: mouse down on scroll rail trigger mousedown_table [#1706](https://github.com/VisActor/VTable/issues/1706)
- **@visactor/vtable**: merge cell value can be edited [#1711](https://github.com/VisActor/VTable/issues/1711)
- **@visactor/vtable**: sub colunms can not be edit when set editor instance [#1711](https://github.com/VisActor/VTable/issues/1711)
- **@visactor/vtable**: fix checkbox and radio state update when change row index [#1712](https://github.com/VisActor/VTable/issues/1712)
- **@visactor/vtable**: fix veritial offset in text stick
- **@visactor/vtable**: fix column width may be zero [#1708](https://github.com/VisActor/VTable/issues/1708)
- **@visactor/vtable**: fix getCell performance
- **@visactor/vtable**: fix header hide func in pivot table
- **@visactor/vtable**: lineDash judgement in group-contribution-render [#1696](https://github.com/VisActor/VTable/issues/1696)
- **@visactor/vtable**: trigger mousedown_table event region need extend [#1668](https://github.com/VisActor/VTable/issues/1668)



[more detail about v0.25.6](https://github.com/VisActor/VTable/releases/tag/v0.25.6)

# v0.25.1

2024-05-08
Expand Down
27 changes: 27 additions & 0 deletions docs/assets/changelog/zh/release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# v0.25.6

2024-05-17


**🆕 新增功能**

- **@visactor/vtable**: 添加 selected_clear 事件 [#1705](https://github.com/VisActor/VTable/issues/1705)
- **@visactor/vtable**: 在事件中添加 mergeCellInfo 参数 [#1667](https://github.com/VisActor/VTable/issues/1667)

**🐛 功能修复**

- **@visactor/vtable**: 在滚动条上按下鼠标触发 mousedown_table 事件 [#1706](https://github.com/VisActor/VTable/issues/1706)
- **@visactor/vtable**: 可编辑合并单元格的值 [#1711](https://github.com/VisActor/VTable/issues/1711)
- **@visactor/vtable**: 修复设置编辑器实例时,子列无法编辑的问题 [#1711](https://github.com/VisActor/VTable/issues/1711)
- **@visactor/vtable**: 修复更改行索引时复选框和单选按钮状态更新问题 [#1712](https://github.com/VisActor/VTable/issues/1712)
- **@visactor/vtable**: 修复文本粘贴时的垂直偏移问题
- **@visactor/vtable**: 修复列宽可能为零的问题 [#1708](https://github.com/VisActor/VTable/issues/1708)
- **@visactor/vtable**: 优化 getCell 性能
- **@visactor/vtable**: 修复透视表中隐藏表头的功能问题
- **@visactor/vtable**: 在渲染中修正 lineDash 判断 [#1696](https://github.com/VisActor/VTable/issues/1696)
- **@visactor/vtable**: 扩展触发 mousedown_table 事件的区域 [#1668](https://github.com/VisActor/VTable/issues/1668)



[更多详情请查看 v0.25.6](https://github.com/VisActor/VTable/releases/tag/v0.25.6)

# v0.25.1

2024-05-08
Expand Down
4 changes: 4 additions & 0 deletions docs/assets/option/en/common/option-secondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,7 @@ Custom cell style assignment
- Single cell: `{ row: number, column: number }`
- Cell range: `{ range: { start: { row: number, column: number }, end: { row: number, column: number} } }`
- customStyleId: Custom style id, the same as the id defined when registering the custom style

#${prefix} enableLineBreak(boolean) = false

Whether to enable line break, the default is false.
4 changes: 4 additions & 0 deletions docs/assets/option/zh/common/option-secondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,7 @@ html 目前实现较完整,先默认使用 html 渲染方式。目前暂不支
- 单个单元格:`{ row: number, column: number }`
- 单元格区域:`{ range: { start: { row: number, column: number }, end: { row: number, column: number} } }`
- customStyleId: 自定义样式 id,与注册自定义样式时定义的 id 相同

#${prefix} enableLineBreak(boolean) = false

是否开启换行符解析,开启后,单元格内容中包含换行符时,会自动解析换行。
43 changes: 39 additions & 4 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4066,7 +4066,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
* 导出某个单元格图片
* @returns base64图片
*/
exportCellImg(col: number, row: number) {
exportCellImg(col: number, row: number, options?: { disableBackground?: boolean; disableBorder?: boolean }) {
const isInView = this.cellIsInVisualView(col, row);
const { scrollTop, scrollLeft } = this;
if (!isInView) {
Expand All @@ -4084,15 +4084,35 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
this.scenegraph.component.hideVerticalScrollBar();
this.scenegraph.component.hideHorizontalScrollBar();

this.scenegraph.renderSceneGraph();
// hide border
this.scenegraph.tableGroup.border.setAttribute('visible', false);

// deal with options
let oldFill;
if (options?.disableBackground) {
const cellGroup = this.scenegraph.getCell(col, row);
oldFill = cellGroup.attribute.fill;
cellGroup.setAttribute('fill', 'transparent');
}
let oldStroke;
if (options?.disableBorder) {
const cellGroup = this.scenegraph.getCell(col, row);
oldStroke = cellGroup.attribute.stroke;
cellGroup.setAttribute('stroke', false);
}

this.scenegraph.renderSceneGraph();
let sizeOffset = 0;
if (this.theme.cellBorderClipDirection === 'bottom-right') {
sizeOffset = 1;
}
const c = this.scenegraph.stage.toCanvas(
false,
new AABBBounds().set(
cellRect.left + this.tableX + 1,
cellRect.top + this.tableY + 1,
cellRect.right + this.tableX,
cellRect.bottom + this.tableY
cellRect.right + this.tableX - sizeOffset,
cellRect.bottom + this.tableY - sizeOffset
)
);
if (!isInView) {
Expand All @@ -4101,12 +4121,27 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
}
// return c.toDataURL('image/jpeg', 0.5);

// restore border
this.scenegraph.tableGroup.border.setAttribute('visible', true);

// restore options
if (oldFill) {
const cellGroup = this.scenegraph.getCell(col, row);
cellGroup.setAttribute('fill', oldFill);
}
if (oldStroke) {
const cellGroup = this.scenegraph.getCell(col, row);
cellGroup.setAttribute('stroke', oldStroke);
}

// restore hover&select style
if (this.stateManager.select?.ranges?.length > 0) {
restoreCellSelectBorder(this.scenegraph);
}
this.stateManager.updateHoverPos(hoverCol, hoverRow);

this.scenegraph.updateNextFrame();

return c.toDataURL();
}

Expand Down
9 changes: 9 additions & 0 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,15 @@ export interface BaseTableAPI {
isAutoRowHeight: (row: number) => boolean;

setSortedIndexMap: (field: FieldDef, filedMap: ISortedMapItem) => void;

exportImg: () => string;
exportCellImg: (
col: number,
row: number,
options?: { disableBackground?: boolean; disableBorder?: boolean }
) => string;
exportCellRangeImg: (cellRange: CellRange) => string;
exportCanvas: () => HTMLCanvasElement;
}
export interface ListTableProtected extends IBaseTableProtected {
/** 表格数据 */
Expand Down

0 comments on commit 35580da

Please sign in to comment.