-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
232 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
s2-site/examples/analysis/conditions/demo/distinguish-cell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { PivotSheet, S2Options, CornerCell } from '@antv/s2'; | ||
|
||
fetch( | ||
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', | ||
) | ||
.then((res) => res.json()) | ||
.then(async (dataCfg) => { | ||
const container = document.getElementById('container'); | ||
|
||
const s2Options: S2Options = { | ||
width: 600, | ||
height: 480, | ||
interaction: { | ||
hoverHighlight: false, | ||
}, | ||
conditions: { | ||
text: [ | ||
// 行头 | ||
{ | ||
field: 'city', | ||
mapping(fieldValue) { | ||
// 如果是角头,fieldValue 就是 城市 | ||
if (fieldValue === '城市') { | ||
return { | ||
fill: 'red', | ||
}; | ||
} | ||
return { | ||
fill: '#DB6BCF', | ||
}; | ||
}, | ||
}, | ||
{ | ||
field: 'type', | ||
mapping(fieldValue, data) { | ||
// 非数据单元格的 data 返回的都是 cell 的 meta 信息 | ||
// 角头单元格独有 cornerType 属性 | ||
if (data.cornerType) { | ||
return { | ||
fill: 'blue', | ||
}; | ||
} | ||
|
||
return { | ||
fill: '#327039', | ||
}; | ||
}, | ||
}, | ||
{ | ||
field: 'sub_type', | ||
mapping(fieldValue, data, cell) { | ||
// cell 是对应当前格子的实例 | ||
if (cell instanceof CornerCell) { | ||
return { | ||
fill: '#BBDEDE', | ||
}; | ||
} | ||
|
||
return { | ||
fill: '#2498D1', | ||
}; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const s2 = new PivotSheet(container, dataCfg, s2Options); | ||
|
||
await s2.render(); | ||
}); |
60 changes: 60 additions & 0 deletions
60
s2-site/examples/analysis/conditions/demo/icon-with-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { PivotSheet, S2Options } from '@antv/s2'; | ||
|
||
fetch( | ||
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', | ||
) | ||
.then((res) => res.json()) | ||
.then(async (dataCfg) => { | ||
const container = document.getElementById('container'); | ||
|
||
const s2Options: S2Options = { | ||
width: 600, | ||
height: 480, | ||
interaction: { | ||
hoverHighlight: false, | ||
}, | ||
headerActionIcons: [ | ||
{ | ||
icons: ['ArrowUp'], | ||
belongsCell: 'rowCell', | ||
}, | ||
{ | ||
icons: ['CellUp'], | ||
belongsCell: 'colCell', | ||
}, | ||
{ | ||
icons: ['CellDown'], | ||
belongsCell: 'cornerCell', | ||
}, | ||
], | ||
conditions: { | ||
icon: [ | ||
{ | ||
field: 'city', | ||
mapping() { | ||
return { | ||
icon: 'Trend', | ||
fill: '#DB6BCF', | ||
}; | ||
}, | ||
}, | ||
{ | ||
field: 'sub_type', | ||
position: 'left', | ||
mapping(fieldValue) { | ||
if (fieldValue !== '子类别') { | ||
return { | ||
icon: 'CellDown', | ||
fill: '#025DF4', | ||
}; | ||
} | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const s2 = new PivotSheet(container, dataCfg, s2Options); | ||
|
||
await s2.render(); | ||
}); |
Oops, something went wrong.