Using d3plus.color.legible, a color's luminosity and saturation can be tweaked so that it is much easier to read on a white background, while still retaining as much of the original color as possible.
This example shows how various colors are modified using this function. The lighter colors are darkened the most.
Featured on D3plus.org