简体   繁体   中英

How to change label color in Morris.js charts?

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.

Does anyone know how to change the label color?

<div id="bar-chart" class="morris-chart" style="height: 180px"></div>

.morris-chart text {
  fill: white;
}

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 Request to Morris.js project so hopefully they will bring that into their master branch.

To change the label color, simply add labelColor property to Morris.Donut config object like below

Morris.Donut({
  labelColor: '#FFF'
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM