Chart.js中的随机填充颜色 [英] Random fill colors in Chart.js

查看:2347
本文介绍了Chart.js中的随机填充颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用nvd3很长时间。在nvd3中,我们有一个选项来指定自动图形填充颜色。

I have been using nvd3 for a long time. In nvd3 we have an option to specify automatic graph fill colors.

chart.barColor()




如何在Chart.js图形中填充随机颜色,而不必在数据集中定义每个
颜色?

How can I fill random colors in Chart.js graphs without defining each color in datasets?

我不想使用JavaScript函数来生成和获取随机颜色。我需要类似于nvd3 barColor()

I don't want to use JavaScript function to generate and get random colors from it. I need something similar to nvd3 barColor()

的类似方法如果有可能的方法,帮助我。

If there is a possible way, then please help me out.

推荐答案

恐怕在chart.js库中没有内置函数。
无论如何,定义自己的javascript函数有什么危害?

I am afraid there just is no in-built function in chart.js library for doing this. And what is the harm in defining your own javascript function anyways?

实现看起来非常类似于你想要的,已经定义了 barColor()会自己做什么。

The implementation would look pretty much similar to what you are looking for, except that you would have defined what barColor() would do yourself.

如果你还没有找到它们,几个很棒的解决方案这里。 (使用JavaScript函数)

If you haven't found them already, there are a couple of great solutions here. (using JavaScript functions)

这篇关于Chart.js中的随机填充颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆