Nvd3.js - it is not possible to change the color of a symbol in a scatter graph

I am trying to change the colors of the different groups of the nvd3 scatterplot here , but I cannot figure out how to do this. I would like to change the colors of series 4 in the example to orange, green, yellow, red.

    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 
    };

I tried

        .color( d3.rgb("green"), d3.rgb("orange") ); 

but then the plot did not even appear. I am new to javascript. So please excuse my mistake if this is too easy.

Edit

I would also like to know how to choose a color based on RGB values.

thank

+1
source share
1 answer

. .

nv.addGraph(function() {
chart = nv.models.scatterChart()
.showDistX(true)
.showDistY(true)
.color(  [d3.rgb("green"), d3.rgb("orange")] ); 
};

, .

EDIT - RGB

css

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

API https://github.com/novus/nvd3/wiki/API-Documentation

+2

Source: https://habr.com/ru/post/1535974/


All Articles