React-vis: Color assignment in DiscreteColorLegend does not match RadialChart

Created on 21 Feb 2018  路  5Comments  路  Source: uber/react-vis

I have a simple radial chart and a corresponding legend. Even though both the radial chart and the legend receive the series data in the same order, the color swatches do not match.

Here's a Codepen.

And a screenshot demonstrating the color difference:

screen shot 2018-02-21 at 4 11 10 pm

bug help wanted

Most helpful comment

Hey @JayFields

I updated your code pen a little bit to get the desired functionality https://codepen.io/anon/pen/EQpKBe, but you do highlight a bug: color should be handled in the legends the same way as everywhere else in the library.

All 5 comments

Hey @JayFields

I updated your code pen a little bit to get the desired functionality https://codepen.io/anon/pen/EQpKBe, but you do highlight a bug: color should be handled in the legends the same way as everywhere else in the library.

Thanks for the workaround!

@mcnuttandrew is the only fix specifying the actual color for each item manually?

Had to spend few hours to find out i was missing colorType="literal". Hope it helps anyone in the future.

After reading the source codes about radical-chart, I found that the color of pie is initiated by:
image
There is no colorDomain as a default props so the radical chart doesn't know which value will be associated with which color. Thus we could add a colorDomain to solve the problem.

Noticing that the colorDomain should be sorted in descending order because the data in the radical chart has been reversed. Besides the length of data cannot exceed 5. If it exceed 5, then use colorType='literal' instead.
image

radical-chart link: https://github.com/uber/react-vis/blob/master/src/radial-chart/index.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codewithsk picture codewithsk  路  5Comments

Falieson picture Falieson  路  3Comments

zavrick picture zavrick  路  4Comments

markov00 picture markov00  路  5Comments

basilaiman picture basilaiman  路  3Comments