javascript 如何更改 Morris.js 图表中的标签颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13811542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change label color in Morris.js charts?
提问by Roman
I'm using morris.js charts which are fantastically easy to setup but I can't workout how to change the color for labels when rendering a Donut graph. By default it prints them in black but I want the graph on top of a dark background.
我正在使用 morris.js 图表,它非常容易设置,但我无法在渲染甜甜圈图时练习如何更改标签的颜色。默认情况下,它以黑色打印它们,但我希望图表位于深色背景之上。
Does anyone know how to change the label color?
有谁知道如何更改标签颜色?
采纳答案by Roman
For the benifet of others I'm going to share how I got around it.
为了其他人的利益,我将分享我是如何解决它的。
It looks like Morris.js currently doesn't support this feature for Donut graphs so I forked the project and made some small changes to support this feature. I also put in a Pull Requestto Morris.js project so hopefully they will bring that into their master branch.
看起来 Morris.js 目前不支持甜甜圈图的此功能,因此我分叉了该项目并进行了一些小的更改以支持此功能。我还向 Morris.js 项目提交了一个Pull Request,所以希望他们能把它带入他们的 master 分支。
回答by Julian Diaz
<div id="bar-chart" class="morris-chart" style="height: 180px"></div>
.morris-chart text {
fill: white;
}
回答by faety_sal
To change the label color, simply add labelColor
property to Morris.Donut config object like below
要更改标签颜色,只需将labelColor
属性添加到 Morris.Donut 配置对象,如下所示
Morris.Donut({
labelColor: '#FFF'
});