Closed tinuts closed 5 years ago
Yes, it's hidden in the dropdown of the Line chart demo, you can add:
<ResponsiveLine
/* … */
colorBy={d => d.color}
/>
you can see it in action on https://nivo.rocks/line in the Style
tab.
@plouc I cannot manage to get working this using colorBy
. I went through the code and I cannot see that there is colorBy
passed to the line. I will investigate what it's the reason but I feel that it will be good to reopen the issue
@EduardoAC the solution was valid at that time, but now you should pass this to colors
instead of colorsBy
.
Could you provide an example of the new format? Currently, I don't manage to get it working at all with
colors= {['#262f3a']}
or
colors="#262f3a"
For the record I tried the https://nivo.rocks/guides/colors without any luck for the line chart. I am currently looking through the code to find the right color
format
@plouc Solved you need to add colors={{ datum: 'color' }}
. Are you sure the documentation is correct for the https://nivo.rocks/guides/colors? I am happy to create a pull request for the docs if Using a static custom color
is mistaken
As well, datum
for the property name is a bit....
Hi so in summary how do we pass our own color palette? https://nivo.rocks/guides/colors doesn't mention that. When you say datum what do you mean, the key of our data? If so how do the existing schemes do colors in a generic way?
@DominicTobias for me what ended up working was passing in an array of colours that was in the same order as the data array
data={ [{id: 'foo', data: lineData}]} colors={['#ff3344']}
That applied the colours as I needed them for my graphs
Hello, I'm new to nivo charts, I'm currently implementing a pie chart in my project, but why the default color scheme only shows one color instead of various color in the specific scheme? What am I missing?
<ResponsivePie data={pieData.data} colors={{ scheme: 'reds' }} margin={{top: 10, right: 10, bottom: 10, left: 10}} borderColor={{ from: 'color', modifiers: [[ 'darker', 0.2 ]] }} />
@Novizh, I don't know what pieData.data
contains, but if you have a look at https://nivo.rocks/pie
, you'll see that you get different colors when using the reds
color scheme. Can you reproduce this on codesandbox for example?
Thanks for the hint @plouc, I figured out that the data inside the pieData.data
only have a label
prop instead of an id
, Nivo charts need an id
to differentiate each data.
I had to manipulate pieData
to have an id
prop with the same values as label.
dashboard.pie.map(item => { let pieData = item.data.map(item => ({ ...item, id: item.label }))
Now the color scheme works as it should.
Passing color like this colors={() => '#ff0000'}
worked for me in ResponsiveLine Chart.
@plouc how can we change node color suppose if i have a blue line then i want its node color to be light blue and if i have a red line then i want its node color to be light red
@DominicTobiaspara mí, lo que terminó funcionando fue pasar una matriz de colores que estaba en el mismo orden que la matriz de datos
data={ [{id: 'foo', data: lineData}]} colors={['#ff3344']}
Eso aplicó los colores como los necesitaba para mis gráficos.
How did you do it, could you be more explicit? Beforehand thank you very much
Hello,
First thx for the amazing work, this lib is awesome !
I just started and struggling with something that should be easy: I would like to simply change lines colors of a
ResponsiveLine
component, maybe I'm missing something...Here is some code:
I assumed the colors provide in data should do the work, but its keep being overrides by default theme :/
(I didn't find anything about it in the doc or google, so I must missing something very obvious maybe, sorry had a long day...)
Thx for help :)