英文:
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));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论