vmpowerio/chartjs-node

When creating a line chart the background is always black

Closed this issue · 1 comments

This is the code that I write:
`var chartNode = new ChartjsNode(600, 600);
return chartNode.drawChart({
type: 'line',
data: {
labels: ["14:00", "14:10", "14:20", "14:30", "14:40", "14:50", "15:00", "15:10", "15:20"],
datasets: [{
label: '# of Viewers',
data: [1000, 1150, 900, 700, 2000, 2200, 2200, 3000, 2500],
backgroundColor: [
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(75, 192, 192, 1)'
],
borderWidth: 1,
fill: true
}]
},
options: {

  responsive: false,
  animation:true
}

})`

but the result is always with black background, why?

Thanks

Don't assign backgroundColor and borderColor as an array of rgba color strings. Assign it directly to a color string
example:
datasets: [ { ... backgroundColor: "rgba(75, 192, 192, 1)", borderColor: "rgba(75, 192, 192, 1)" ... } ]

This should solve your issue.