Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda