Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

421
Visualizações
How to change colors in react charts

I'm making a chart and im kind of confused. ill attach a photo below enter image description here

So first off, I want the title to not be undefined, how do I change the title? And I want to change the background color of the chart below the lines, heres my code

{data?.length > 0 && (
            <Line
            
            options={options}
           height={"300%"}
           
            
            data={{
                datasets: [
                    {
                    backgroundColor: "rgba(204, 16, 52, 0.5)",
                    borderColor: "#CC1034",
                    data: data,
                    
                }
            ]
                
            }}
            
            />  
        )}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The legend label will be correctly displayed if you define label on your dataset, this was mentioned by WhiteHat in his comment.

In order to obtain the background color below the lines (basically an area chart), you need to add fill: true to the dataset.

To make it work, you also need to import and register Filler from chart.js.

Please take a look at this Code Sandbox and see how it works.

about 4 years ago · Juan Pablo Isaza Relatório

0

Here's how I added styled to my chart:

function MyChart({}) {
  const { data } = useChartConfig({
    height: 200,
    grouping: "primary",
    dataType: "ordinal",
  });

  const getSeriesStyle = React.useCallback((series) => {
    // Based off my chart bars
    const colorPalette = {
      series1: "#354657",
      series2: "#5597e2",
      series3: "#28A96C",
      series4: "#d44401",
      series5: "#ffe65b",
      series6: "#ffab1b",
    };

    return {
      fill: colorPalette[series.label],
    };
  }, []);

  return <Chart data={data} getSeriesStyle={getSeriesStyle} />;
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda