简体   繁体   English

使用CSS3关键帧超级彩虹来更改javascriptoughnutData的颜色

[英]Using CSS3 keyframes super-rainbow to change color of javascript doughnutData

I am using javascript doughnutData on my websites. 我在我的网站上使用javascriptoughnutData。 I have successfully applied super-rainbow to text (an effect that changes text color). 我已经成功地将超级彩虹应用于文本(一种改变文本颜色的效果)。 Is there anyway to target the color value within the the javascript and apply the CSS3 rainbow effect? 无论如何,要在javascript中定位颜色值并应用CSS3彩虹效果?

var doughnutData = [
                                {
                                    value: 70,
                                    color:"#74cfae"
                                }

They keyframe code I am using is as follows: 他们正在使用的关键帧代码如下:

-webkit-animation: super-rainbow 2s infinite linear;
    -moz-animation: super-rainbow 2s infinite linear;
    -o-animation: linear-super-rainbow 2s infinite linear;
    -ms-animation: linear-super-rainbow 2s infinite linear;
}

    @-webkit-keyframes super-rainbow {
    0% {
        color: #333;
    }
    20% {
        color:#06C;
    }
    40% {
        color:#090;
    }
    60% {
        color:#FC0;
    }
    80% {
        color:#F00;
    }
    100% {
        color:#606;
    }
    }
@-moz-keyframes super-rainbow {
    0% {
        color: #333;
    }
    20% {
        color:#06C;
    }
    40% {
        color:#090;
    }
    60% {
        color:#FC0;
    }
    80% {
        color:#F00;
    }
    100% {
        color:#606;
    }
}
    @-o-keyframes super-rainbow {
    0% {
        color: #333;
    }
    20% {
        color:#06C;
    }
    40% {
        color:#090;
    }
    60% {
        color:#FC0;
    }
    80% {
        color:#F00;
    }
    100% {
        color:#606;
    }
    }
    @-ms-keyframes super-rainbow {
    0% {
        color: #333;
    }
    20% {
        color:#06C;
    }
    40% {
        color:#090;
    }
    60% {
        color:#FC0;
    }
    80% {
        color:#F00;
    }
    100% {
        color:#606;
    }
}

The library you want to use (chart.js), uses canvas object to draw to. 您要使用的库(chart.js)使用canvas对象绘制。 What this mean, in a few words: The content is not HTML based. 简而言之,这意味着什么:内容不是基于HTML的。

What would lead to: If it's not HTML, CSS do not apply to it... 会导致什么:如果不是HTML,则CSS不适用于它...

chart.js uses a Canvas, and draws charts as primitives as they are (lines, squares, circles, elipses...). chart.js使用Canvas,并按原样绘制图表(线条,正方形,圆形,椭圆形...)。 They do not contain div , ul , span ... And this is a good reason: Rendering is faster and more controllable. 它们不包含divulspan ……这是一个很好的理由:渲染更快,更可控。

However, because of this, the answer for your question is no . 但是,因此,您的问题的答案为no That effect you made cannot be set in the properties, because it wont work. 您无法在属性中设置该效果,因为它无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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