-
Notifications
You must be signed in to change notification settings - Fork 605
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
test(pattern): 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 #2786
Conversation
* feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数
@@ -0,0 +1,78 @@ | |||
import { getCanvasPattern, PatternOption } from '../../../../src/utils/pattern/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/index
可以不需要
* fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
Pull Request Test Coverage Report for Build 1119443972
💛 - Coveralls |
expect(cfg.items[0].marker.style.fill).toBe('#5B8FF9'); | ||
expect(cfg.items[1].marker.style.fill).toBe('#5AD8A6'); | ||
|
||
dualAxes.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个为啥会在这个分支上?
|
||
it('line-pattern without cfg', () => { | ||
const pattern = getCanvasPattern({ type: 'line' }); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上。
@@ -11,9 +11,10 @@ export type PatternCfg = { | |||
strokeOpacity?: number; | |||
/** lines thickness. 描边粗细 */ | |||
lineWidth?: number; | |||
|
|||
/** 图案以及背景色 */ | |||
opacity?: number; // 整个贴图透明 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两种类型的注释,可以把后面的这个删除。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好👌👌
@@ -77,30 +79,34 @@ export function createDotPattern(cfg: DotPatternCfg): CanvasPattern { | |||
stroke: 'transparent', | |||
lineWidth: 0, | |||
isStagger: true, | |||
mode: 'repeat', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deepAssign 的第一个 {} 不需要。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
反驳你,导致 defaultOption 一直被 mutable 了
// 绘制图案 | ||
for (const [x, y] of dots) { | ||
drawDot(ctx, dotCfg, x, y); | ||
} | ||
|
||
return ctx.createPattern(canvas, cfg.mode || 'repeat'); | ||
return ctx.createPattern(canvas, dotCfg.mode || 'repeat'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeat 不是作为 default 配置了嘛?这了还需要兜底嘛?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对哦,,我修改一下👌👌
it('pattern with error type', () => { | ||
//@ts-ignore | ||
const pattern = getCanvasPattern({ type: 'xxx' }); | ||
expect(pattern).toEqual(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:单侧内容只有 instanceOf 和 undefined 的内容,没有其他分支的内容。是因为 dot 没有其他可测的是嘛?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dot,line等文件中的方法会再拿出来测试一下~等下就补充
}, | ||
}, | ||
userMarker | ||
)) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个记录是其他 pr 分支的吧?
unitSize *= 2; | ||
} | ||
|
||
initCanvas(canvas, size, unitSize); | ||
initCanvas(canvas, unitSize, unitSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initCanvas 可以把 createElement('canvas') 包含进去嘛?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯👌👌
* feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * chore: 升级官网 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * 修复: [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 (#2776) * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * refactor: 修改pattern单测中的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: visiky <736929286@qq.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
* feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * chore: 升级官网 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * 修复: [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 (#2776) * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * refactor: 修改pattern单测中的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: visiky <736929286@qq.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
* feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * chore: 升级官网 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * 修复: [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 (#2776) * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * refactor: 修改pattern单测中的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: visiky <736929286@qq.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
* feat: 初始化pattern (#2763) Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * feat(pattern): 增加可配置的dot贴图,并将patternAdaptor用于饼图 (#2766) * feat: 初始化pattern * feat: 增加可配置的dot贴图,并将patternAdptor用于饼图 * refactor: 将pattern统一赋给color,不用style Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * feat: Upgrade pattern (#2778) * feat(pattern): pattern 填充作用在 style 上 * feat(pattern): pattern 通道 & 接入柱条形图、玉珏图 * docs(pattern-demo): 增加若干 demo * refactor: 优化下代码 * docs: 增加 demos 上新标识 * refactor(pattern): 修改 cr 内容 & 优化 demo * feat(line-pattern): 添加linePattern (#2780) * feat: 初始化pattern * feat: 增加可配置的dot贴图,并将patternAdptor用于饼图 * feat: 初始化pattern (#2763) Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * refactor: 将pattern统一赋给color,不用style * fix: 修改pattern文件引入路径 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * refactor(pattern): 内置 pattern 不使用 class 的方式 (#2781) * feat(square-pattern): 添加square样式贴图 (#2782) * feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test(pattern): 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 (#2786) * feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * chore: 升级官网 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * 修复: [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 (#2776) * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * refactor: 修改pattern单测中的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: visiky <736929286@qq.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * refactor(pattern): 优化pattern的写法,抽出一些方法 (#2788) * refactor(pattern): 优化代码写法 * refactor(pattern): 优化pattern的写法,抽出一些方法 * refactor(pattern): 抽出util文件 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * fix(pattern): 解决 pattern 展示模糊问题 * docs(pattern): 优化下demo * fix(pattern): 修复square pattern 旋转问题 & 优化默认配置参数 * refactor(pattern): 使用setTransform方法,rotation作用于整个pattern画布 (#2789) * refactor(pattern): 使用setTransform方法,rotation作用于整个pattern画布 * refactor: 处理transformMatrix成纯函数 * refactor: 处理transformMatrix成纯函数 * test(dot and util): 添加dotPattern和util的单测,并添加getPixelColor获取像素点方法 * test(line-pattern): 添加linePattern的单测 * test(square-pattern): 添加squarePattern的单测 * refactor: 修改变换矩阵的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * docs(pattern): 添加pattern的文档 (#2798) * docs: 添加pattern的demo (#2799) Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * refactor: 抽取获取设备像素比的 util * docs(pattern): pattern 文档完善 * docs: 完善 legend marker 配置文档 & 优化 pattern demo * fix(pattern): 修复 dot pattern 单测 * feat(pattern): 直方图、水波图、矩阵树图添加 pattern * test(pattern): 增加 pattern adaptor 的单测 * chore: 优化官网展示 * feat(pattern): 面积图、热力图、迷你柱状图接入 pattern * fix: 修复单测 * fix: 尝试修复单测 * fix(line-pattern): 修复linewidth>=spacing 时,绘制异常问题 (#2801) * test(pattern-in-plot): 逐个给每个plot添加pattern的单测,并添加对应的pattern文档 (#2805) * test(pattern-in-plot): 逐个给每个plot添加pattern的单测,并添加对应的pattern文档 * docs: 修改部分pattern的文档说明以及默认值等 * fix: 修复pattern回调问题,对应的图形如果没有pattern,默认为主题色 * test: 添加column引入pattern的单测,并添加文档 * test: 添加bar引入pattern的单测,并添加文档 * test: 给pie添加pattern的单测,添加文档 * fix(pattern-util): 处理color为数组导致pie的图形变黑情况,统一返回字符串 * test: 给直方图添加pattern的单测,增加文档 * test: 给treemap添加pattern的单测,增加文档 * test: 给heatmap添加pattern的单测和文档,并给patternAttr的类型增加布尔值 * test: 给radial-bar添加pattern的单测,增加文档 * test: 给tiny-column添加pattern的单测,增加文档 * test: 给circle-packing添加pattern的单测,增加文档 * docs: 修改接入文档方式,把标题抽出来 * fix: 给patternAdaptor补充stackFields映射字段,修复stack模式的直方图添加pattern变黑问题 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> * docs: 更新 pattern demo 的截图 * feat(pattern): 修改下 pattern adaptor 获取 color & 旭日图支持 pattern * fix: 修复一些 lint 问题 * feat(tiny-area): 迷你面积图支持 pattern,同时添加 pattern 与渐变色无法共存的说明文档 (#2811) * feat(rose): 玫瑰图支持 pattern & demo (#2810) * feat(liquid): 水波图支持 pattern & demo (#2812) * test: 补充旭日图等单测和文档 (#2815) * test: 补充其旭日图等单测和文档 * refactor: 删除pattern的boolean类型 * test(pattern): 添加rose、tiny-area、liquid的单测和文档 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: Visiky <736929286@qq.com> * feat(dual-axes): 双轴图支持 pattern (#2813) Co-authored-by: Susan <527971893@qq.com> Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
PR includes
Screenshot