如何在amcharts5中更改主按钮的颜色?

huangapple go评论97阅读模式
英文:

How to change primaryButton color in amcharts5?

问题

我正在尝试更改amcharts5中的"zoomOut"按钮或称为"primaryButton"的颜色。但是,通过查阅文档,我找不到适用的方法。

  1. var root = am5.Root.new(divId);
  2. root._logo.dispose();
  3. var fpTheme = am5.Theme.new(root);
  4. fpTheme.rule("Label").setAll({
  5. fontSize: "1rem",
  6. fill: am5.color(0x97a0b4)
  7. });
  8. fpTheme.rule("LineSeries").adapters.add("stroke", function(stroke, target) {
  9. return am5.color(0x4ac445);
  10. });
  11. // 以下代码不起作用,但上面的代码运行正常。
  12. fpTheme.rule("Button").setAll({
  13. minus: {
  14. fill: am5.color(0x4ac445)
  15. }
  16. });
  17. fpTheme.rule("Graphics").setAll({
  18. minus: {
  19. fill: am5.color(0x4ac445)
  20. }
  21. });
  22. root.setThemes([
  23. am5themes_Animated.new(root),
  24. fpTheme
  25. ]);

单击"zoomOut"按钮会显示绿色 "#4ac445",但按钮仍然是蓝色的,类似于文档中的示例 https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/

英文:

I'm trying to change the color of zoomOut button or so called "primaryButton" in amcharts5. However digging through documentation i couldn't find anything that works.

  1. var root = am5.Root.new(divId);
  2. root._logo.dispose();
  3. var fpTheme = am5.Theme.new(root);
  4. fpTheme.rule("Label").setAll({
  5. fontSize: "1rem",
  6. fill: am5.color(0x97a0b4)
  7. // fill: am5.color(0x777777)
  8. // minGridDistance: 30
  9. });
  10. fpTheme.rule("LineSeries").adapters.add("stroke", function(stroke, target) {
  11. // console.log(stroke);
  12. // return am5.color(0x4CAF50);
  13. return am5.color(0x4ac445);
  14. });
  15. // this below doesn't work. The above code works just fine.
  16. fpTheme.rule("Button").setAll({
  17. minus: {
  18. fill: am5.color(0x4ac445)
  19. }
  20. });
  21. fpTheme.rule("Graphics").setAll({
  22. minus: {
  23. fill: am5.color(0x4ac445)
  24. }
  25. });
  26. root.setThemes([
  27. am5themes_Animated.new(root),
  28. fpTheme
  29. ]);

Clicking on zoomOut button does show that green color "0x4ac445" but the button is still blue like this from docs https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/

答案1

得分: 1

我已检查此代码,它可以正常运行。

  1. // 将缩放按钮颜色更改为红色
  2. root.interfaceColors.set("primaryButton", am5.color(0xff0000));
  3. // 将缩放按钮悬停颜色更改为黑色
  4. root.interfaceColors.set("primaryButtonHover", am5.color(0x000000));
英文:

I've checked this code and it works fine.

  1. // change zoom button color to red
  2. root.interfaceColors.set("primaryButton", am5.color(0xff0000));
  3. // change zoom button-hover color to black
  4. root.interfaceColors.set("primaryButtonHover", am5.color(0x000000));

huangapple
  • 本文由 发表于 2023年6月15日 21:31:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483012.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定