1

Does anyone know how to create custom colors on a d3 treemap without using color2 = d3.scale.category20c(); or d3.scale.category10c();?

Thanks so much if you do.

Mr. Concolato
  • 2,224
  • 5
  • 24
  • 44

1 Answers1

3

category10() is just a special ordinal scale. You can make another with your own colors:

color = d3.scaleOrdinal().range(['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd'])
Adam Pearce
  • 9,243
  • 2
  • 38
  • 35
  • 1
    Not sure about that, but i found a solution for myself, which i will share. I tried creating an assoc array of colors: var colorArr = new Array(); colorArr["Agricultural Products"] = "#31a354"; colorArr["Animal & Animal Products"] = "#9ecae1"; ...etc Then used a for loop to loop through the treemap nodes and assign colors to parent nodes. Hope that helps anyone else that may have suffered the same plight as i on this. – Mr. Concolato Jun 04 '13 at 14:34