Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!