gpt4 book ai didi

javascript - Charts.js 未使用正确的颜色

转载 作者:行者123 更新时间:2023-12-02 14:45:44 25 4
gpt4 key购买 nike

js 在我的应用程序中绘制图表,但它没有使用正确的颜色,我在这里粘贴一个 jsfiddle 看看是否有人能看到错误,(我的问题是两个部分具有相同的颜色,即使我指定它不同,当我将鼠标悬停在“二”部分时,三个也会突出显示)

var c = document.getElementById('mcanvas');
var ctx = c.getContext("2d");
var data = [
{"value":1,"label":"One","color":"#6e2a89","highlight":"#f00"},{"value":1,"label":"Two","color":"#b26b65","highlight":"#f00"},{"value":3,"label":"Three","color":"#f42be","highlight":"#f00"},{"value":1,"label":"Four","color":"#57b893","highlight":"#f00"},{"value":7,"label":"Five","color":"#4b8752","highlight":"#f00"},{"value":0,"label":"Six","color":"#ff7e9","highlight":"#f00"}];
var ch = new Chart(ctx).Pie(data, {});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
<canvas id="mcanvas"></canvas>

最佳答案

三位数的颜色是 5 位数字。不确定为什么会导致这种行为。但解决这个问题就能解决你的问题。

关于javascript - Charts.js 未使用正确的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36632714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com