Javascript nvd3.js-无法更改散点图中符号的颜色

Javascript nvd3.js-无法更改散点图中符号的颜色,javascript,d3.js,nvd3.js,scatter-plot,color-scheme,Javascript,D3.js,Nvd3.js,Scatter Plot,Color Scheme,我试图改变nvd3散点图不同组的颜色,但无法理解如何做到这一点。我想将示例中4个系列的颜色更改为橙色、绿色、黄色和红色 nv.addGraph(function() { chart = nv.models.scatterChart() .showDistX(true) .showDistY(true) .color( d3.scale.category10().range() ); // tried to change to green, orange

我试图改变nvd3散点图不同组的颜色,但无法理解如何做到这一点。我想将示例中4个系列的颜色更改为橙色、绿色、黄色和红色

    nv.addGraph(function() {
    chart = nv.models.scatterChart()
    .showDistX(true)
    .showDistY(true)
    .color( d3.scale.category10().range() ); //  tried to change to green, orange here but it did not work 
    };
我试过了

        .color( d3.rgb("green"), d3.rgb("orange") ); 
但后来情节甚至没有出现。我是javascript新手。如果我的错误太简单,请原谅

编辑

我也想知道如何根据RGB值选择颜色


谢谢

颜色函数采用一系列颜色。对于散点图,这相当于每个数据组一种颜色

如果你把它改成

nv.addGraph(function() {
chart = nv.models.scatterChart()
.showDistX(true)
.showDistY(true)
.color(  [d3.rgb("green"), d3.rgb("orange")] ); 
};
它似乎能满足你的需要

编辑-使用RGB字符串设置颜色

这可以使用css语法完成

 nv.addGraph(function() {
chart = nv.models.scatterChart()
.showDistX(true)
.showDistY(true)
.color(  ["rgb(0,255,0)","rgb(255,165,0)"] ); 
};

您最好阅读位于

的API文档。我们可以指定RGB值而不是
绿色
橙色
?您可以使用css语法吗?您可以回答这个问题吗?我面临类似的问题-