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

236
Visualizações
Plotly.js Bar Chart data argument is not assignable to parameter of type 'Data[]'

I am new to plotly and I'm currently trying to replicate a straight forward bar chart : Link.

I have created an angular component for the same and I installed the package via: npm i --save plotly.js-dist-min

Here is the code:

var xArray = ["Italy", "France", "Spain", "USA", "Argentina"];
var yArray = [55, 49, 44, 24, 15];

var data = [{
  x:xArray,
  y:yArray,
  type: "bar"
}];

var layout = {title:"World Wide Wine Production"};

Plotly.newPlot("bars", data, layout);

The error goes away when I remove type: "bar". However, I get a line chart when type is removed.

and the error displayed is:

Argument of type '{ x: string[]; y: number[]; type: string; }[]' is not assignable to parameter of type 'Data[]'. Type '{ x: string[]; y: number[]; type: string; }' is not assignable to type 'Data'. Type '{ x: string[]; y: number[]; type: string; }' is not assignable to type 'Partial'. Types of property 'type' are incompatible. Type 'string' is not assignable to type '"violin" | undefined'.

 Plotly.newPlot("my_bars", data, layout);

I get a similar error for type: pie :

error TS2345: Argument of type '{ labels: string[]; values: number[]; type: string; }[]' is not assignable to parameter of type 'Data[]'. Type '{ labels: string[]; values: number[]; type: string; }' is not assignable to type 'Data'. Type '{ labels: string[]; values: number[]; type: string; }' is not assignable to type 'Partial'. Types of property 'type' are incompatible. Type 'string' is not assignable to type '"pie" | undefined'.

 Plotly.newPlot("my_pie", data, layout);
about 4 years ago · Juan Pablo Isaza
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