Skip to content
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

4.x 如何注册主题, 如何动态切换主题 #2258

Closed
chen900112 opened this issue Apr 1, 2020 · 6 comments · Fixed by #2262
Closed

4.x 如何注册主题, 如何动态切换主题 #2258

chen900112 opened this issue Apr 1, 2020 · 6 comments · Fixed by #2262
Assignees
Labels

Comments

@chen900112
Copy link

  • G2 Version:4.0.3
  • Platform:
  • Mini Showcase(like screenshots):
  • CodePen Link:

https://antv-g2.gitee.io/zh/docs/manual/tutorial/theme
按照文档无法注册主题,并且动态切换他
能否提供一个思路
官网没有提供主题模板,通过全局的getTheme可以看到主题参数,我该怎么做?
复制 getTheme的结果json 保存到本机文件?

@simaQ simaQ self-assigned this Apr 2, 2020
@simaQ
Copy link
Contributor

simaQ commented Apr 2, 2020

  1. 如何动态切换主题?
chart.theme('dark');
chart.render(true); // 关键一步,需要手动更新
  1. 如何获取主题模板?

    是可以通过 chart.getTheme() 获取全部的属性结构,在开发者教程中,已经比较详细说明了:


抱歉,文档没有补充完整,等下我补充下。

@chen900112
Copy link
Author

G((O5HLQNX(QFR3H 3BWBFC
LTPE$D2@PLBP )6JCEAP@G
我是这么做的对吗
问题:初始化的时候 clone 多次感觉会很慢?
文档里面是写的是colors 但是实际好像是colors10

@simaQ
Copy link
Contributor

simaQ commented Apr 2, 2020

恩,文档我在更新了。

目前主题设置这里有个问题,就是如果传入 chart.theme() 方法的参数是字符串,即已经注册的主题名的话 ,内部还会和默认的主题 merge 一边,这样在你这个场景下就增加了一倍对象复制开销,这个我今天修复一下。

另外如果支持更新色板的话,可以直接:

chart.theme({
  defaultColor: '',
  colors10: [],
});

@simaQ simaQ added the Bug label Apr 2, 2020
@chen900112
Copy link
Author

WNN@HG7E39OH7}C)H9UMH1D
HRVW1TMEH%_V(US5)`)CYIJ
尝试使用这个方式但是好像并不对
%(2T8S9GBPPZ~(OD~PY$1X7
这个对了,大致理解

@simaQ
Copy link
Contributor

simaQ commented Apr 2, 2020

恩,是个 BUG, 4.0.4 版本会修复

@chen900112
Copy link
Author

@simaQ #2260
能不能给个思路尝试了几种都不行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants