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

217
Views
Chartjs background black after adding canvas

I have this problem that my linechart has an black background while barchart works fine.

enter image description here

Here is my code:

let colors = getGradientColors(...colorPalette[key]);
let gradient = ctx.createLinearGradient(0, 0, 0, gradientHeight);
console.log(gradient, colors.full, colors.transparent, gradientHeight);
gradient.addColorStop(0, colors.full);
gradient.addColorStop(1, colors.transparent);

let dataset: ChartDatasetExtended = {
  label: t("community.group." + key) || "",
  //@ts-ignore
  //TODO: Check later TS error
  data: data[key],
  borderColor: colors.line,
  fill: true,
  backgroundColor: gradient,
  borderWidth,
  cubicInterpolationMode: "monotone",
  tension: 0.4,
  gradientColor: colors,
};

The console.log output you can see inside the image.

Barchart works fine with this code, while this linechart is just black.

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!