-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S2自定义单元格为图片,图表滚动时,图片资源反复加载🐛 #1499
Comments
S2 考虑内置 |
这个不就是官网的自定义data-cell吗 |
这是来自QQ邮箱的假期自动回复邮件。
您好,你的邮件我已经收到。
|
这是来自QQ邮箱的假期自动回复邮件。
您好,你的邮件我已经收到。
|
没明白解决方案是什么 ? |
这是来自QQ邮箱的假期自动回复邮件。
您好,你的邮件我已经收到。
|
解决了吗? |
这是来自QQ邮箱的假期自动回复邮件。
您好,你的邮件我已经收到。
|
你好 @X-x-start,该功能或缺陷已经在 如有任何 yarn add @antv/s2@next # pnpm add @antv/s2@next
yarn add @antv/s2-react@next # pnpm add @antv/s2-react@next
yarn add @antv/s2-vue@next # pnpm add @antv/s2-vue@next Hello, @X-x-start, This feature or flaw has been supported or fixed in Any |
🏷 Version
Sheet Type
🖋 Description
S2自定义单元格为图片,图表滚动时,图片资源反复加载
⌨️ Code Snapshots
import React from 'react';
import ReactDOM from 'react-dom';
import insertCss from 'insert-css';
import { SheetComponent } from '@antv/s2-react';
import { DataCell } from '@antv/s2';
import '@antv/s2-react/dist/style.min.css';
const paletteLegendMap = [
{
text: '睡觉',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/AzGyiSa2A8ZMAAAAAAAAAAAAAARQnAQ',
},
{
text: '工作',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/ARdyWRpg3hRAAAAAAAAAAAAAAARQnAQ',
},
{
text: '上学',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*1p5iTYDCkKEAAAAAAAAAAAAAARQnAQ',
},
{
text: '吃饭',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*XHHcSZxmR7gAAAAAAAAAAAAAARQnAQ',
},
{
text: '学习',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*1p5iTYDCkKEAAAAAAAAAAAAAARQnAQ',
},
{
text: '娱乐',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*ZRaUT55QCaoAAAAAAAAAAAAAARQnAQ',
},
{
text: '运动',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*xpO5Sawk8YIAAAAAAAAAAAAAARQnAQ',
},
{
text: '其他',
img: 'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*e5A3SKifw1EAAAAAAAAAAAAAARQnAQ',
},
];
// 自定义单元格
class CustomDataCell extends DataCell {
drawTextShape() {
const { fieldValue } = this.meta;
const url =
paletteLegendMap.find((v) => v.text === fieldValue)?.img ??
'https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*e5A3SKifw1EAAAAAAAAAAAAAARQnAQ';
const img = new Image();
img.src = url;
const { x, y, width, height } = this.meta;
img.onload = () => {
this.textShape = this.addShape('image', {
attrs: {
x: x + (width - img?.width) / 2,
y: y + (height - img?.height) / 2,
width: img?.width ?? width,
height: img?.height ?? height,
img: url,
},
});
};
}
}
fetch('../data/time-spend.json')
.then((res) => res.json())
.then((s2DataConfig) => {
const s2Theme = {
colCell: {
text: {
opacity: 0,
},
bolderText: {
opacity: 0,
},
cell: {
backgroundColor: '#020138',
},
},
rowCell: {
text: {
opacity: 0,
},
bolderText: {
opacity: 0,
},
cell: {
horizontalBorderColorOpacity: 0,
verticalBorderColorOpacity: 0,
backgroundColor: '#020138',
interactionState: {
// -------------- hover -------------------
hover: {
backgroundColor: 'rgba(255,255,255,0.18)',
},
// -------------- selected -------------------
selected: {
backgroundColor: 'rgba(255,255,255,0.18)',
},
},
},
},
dataCell: {
cell: {
horizontalBorderColorOpacity: 0,
verticalBorderColorOpacity: 0,
crossBackgroundColor: '#020138',
backgroundColor: '#020138',
interactionState: {
// -------------- hover -------------------
hover: {
backgroundColor: 'rgba(255,255,255,0.18)',
},
// -------------- keep hover -------------------
hoverFocus: {
backgroundColor: 'rgba(255, 255, 255, 0.18)',
borderOpacity: 0,
},
// -------------- selected -------------------
selected: {
backgroundColor: 'rgba(255,255,255,0.18)',
},
},
},
},
cornerCell: {
bolderText: {
opacity: 0,
},
cell: {
horizontalBorderColorOpacity: 0,
verticalBorderColorOpacity: 0,
backgroundColor: '#020138',
},
},
splitLine: {
horizontalBorderColorOpacity: 0,
verticalBorderColorOpacity: 0,
},
background: {
color: '#020138',
},
};
});
// 我们用 insert-css 演示引入自定义样式
// 推荐将样式添加到自己的样式文件中
// 若拷贝官方代码,别忘了 npm install insert-css
insertCss(
.sheet-wrapper { background: #010138; padding: 16px; } .palette { display: flex; width: 100%; overflow: hidden; margin-bottom: 16px; margin-left: 88px; } .palette-group { display: flex; } .palette-img { width: auto; height: 20px; } .palette-text { color: #FFF; width: 50px; font-size: 12px; padding-left: 8px; }
);🔗 Reproduce Link
🤔 Steps to Reproduce
😊 Expected Behavior
期望重复图片资源可以不用重复加载
😅 Current Behavior
图片资源反复加载 图片大还会出现闪烁 demo可使用官网demo 将图表高度改为200
https://s2.antv.vision/zh/examples/case/art#time-spend-abstract
💻 System information
The text was updated successfully, but these errors were encountered: