logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
epf  
#1 Posted : Wednesday, July 8, 2015 3:49:15 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
For a specific chart,
you can force the colors chosen for the NVD3 Chart by editing
the NVD3 Chart Configuration script of your model:

just replace
Code:

.color(d3.scale.category10().range())

by the colors needed
Code:

.color(['blue','green','red','yellow'])

to force the colors...

and thats it !
Patrick  
#2 Posted : Tuesday, November 3, 2015 7:04:07 AM(UTC)
Patrick

Rank: Newbie

Groups: Registered
Joined: 11/3/2015(UTC)
Posts: 1
Belgium
Location: Gent

Hello,

This works but.....

The colors change according to the result set.
I read that you should be able to link a color to a certain domain
For example using a splitter field

Category HIGH ---> RED
Category MEDIUM --> ORANGE
Category LOW ---> GREEN

Th color should contain a range defining the Hex values of the color
And there should also be a domain, corresponding to each field having a specific color defined in range.

I see some examples on the net, but cant seem to make it work.


http://stackoverflow.com...scale-in-a-d3-line-chart

https://github.com/mbostock/d3/wiki/Ordinal-Scales


Any ideas, i am,completely stuck and already spent hours looking for a solutiion
Thanks

Edited by user Tuesday, November 3, 2015 7:30:55 AM(UTC)  | Reason: Typos

epf  
#3 Posted : Tuesday, November 3, 2015 8:37:06 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
I found another way you can try, just add the following function you can customize (tested on Northwind on the product category):

Code:

chart.color(function(d) {
  if (xLabels[d.x] == 'Condiments') return 'yellow';
  return 'green';
});


it actually uses the x value of the point and the xLabels array defined for the chart.

Good luck.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.