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

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

How to change primaryButton color in amcharts5?

问题

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

var root = am5.Root.new(divId);
root._logo.dispose();

var fpTheme = am5.Theme.new(root);

fpTheme.rule("Label").setAll({
    fontSize: "1rem",
    fill: am5.color(0x97a0b4)
});

fpTheme.rule("LineSeries").adapters.add("stroke", function(stroke, target) {
    return am5.color(0x4ac445);
});

// 以下代码不起作用,但上面的代码运行正常。
fpTheme.rule("Button").setAll({
    minus: {
        fill: am5.color(0x4ac445)
    }
});

fpTheme.rule("Graphics").setAll({
    minus: {
        fill: am5.color(0x4ac445)
    }
});

root.setThemes([
    am5themes_Animated.new(root),
    fpTheme
]);

单击"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.

var root = am5.Root.new(divId);
root._logo.dispose();

var fpTheme = am5.Theme.new(root);

fpTheme.rule("Label").setAll({
    fontSize: "1rem",
    fill: am5.color(0x97a0b4)
    // fill: am5.color(0x777777)
    // minGridDistance: 30
});

fpTheme.rule("LineSeries").adapters.add("stroke", function(stroke, target) {
    // console.log(stroke);
    // return am5.color(0x4CAF50);
    return am5.color(0x4ac445);
});

// this below doesn't work. The above code works just fine.

fpTheme.rule("Button").setAll({
    minus: {
        fill: am5.color(0x4ac445)
    }
});

fpTheme.rule("Graphics").setAll({
    minus: {
        fill: am5.color(0x4ac445)
    }
});

root.setThemes([
    am5themes_Animated.new(root),
    fpTheme
]);

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

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

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

I've checked this code and it works fine.

// change zoom button color to red
root.interfaceColors.set("primaryButton", am5.color(0xff0000));

// change zoom button-hover color to black
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:

确定