I have developed a code that generates line graphs on an SVG canvas, however, I am facing difficulties in altering the colors as I defined using the d3.scaleOrdinal function.
Despite defining 12 distinct colors, the output I am getting looks like this. Is there anyone who can assist me with this? Thank you.
var colorScheme = d3.scaleOrdinal().range([
'#673ab7',
'#9c27b0',
'#e91e63',
'#f44336',
'#ff5722',
'#ff9800',
'#ffc107',
'#ffeb3b',
'#cddc39',
'#8bc34a',
'#4caf50',
'#009688'])
.domain(d3.range(1,13));
var line = d3.line()
.x(function(d) { return x(d.day); })
.y(function(d) { return y(d.temp); });
var generateLineChart = function(csvfile, i) {
d3.csv(csvfile, function(error, data){
data.forEach(function(d){
d.month = +d.month,
d.day= +d.day,
d.temp= +d.temp;
});
svg.append('path')
.data([data])
.attr('class','line')
.style('stroke', function(i){ return colorScheme(i);})
.attr('d', line);
}); //end of read csv
}; //end of line chart
generateLineChart('/static/data/temp1.csv'1);
generateLineChart('/static/data/temp2.csv'2);
generateLineChart('/static/data/temp3.csv'3);
generateLineChart('/static/data/temp4.csv'4);
generateLineChart('/static/data/temp5.csv',5);
generateLineChart('/static/data/temp6.csv',5);
generateLineChart('/static/data/temp7.csv',6);
generateLineChart('/static/data/temp8.csv',7);
generateLineChart('/static/data/temp9.csv',8);
generateLineChart('/static/data/temp10.csv',80);
generateLineChart('/static/data/temp11.csv',90);
generateLineChart('/static/data/temp12.csv',100);