Linear gradient doesn't work on backgroundColor prop
See original GitHub issueSandbox: https://codesandbox.io/s/distracted-feynman-tnn96
function createGradient(ctx: CanvasRenderingContext2D, area: ChartArea) {
const colorStart = faker.random.arrayElement(colors);
const colorMid = faker.random.arrayElement(
colors.filter((color) => color !== colorStart)
);
const colorEnd = faker.random.arrayElement(
colors.filter((color) => color !== colorStart && color !== colorMid)
);
const gradient = ctx.createLinearGradient(0, area.bottom, 0, area.top);
gradient.addColorStop(0, colorStart);
gradient.addColorStop(0.5, colorMid);
gradient.addColorStop(1, colorEnd);
return gradient;
}
useEffect(() => {
const chart = chartRef.current;
if (!chart) {
return;
}
const chartData = {
...data,
datasets: data.datasets.map((dataset) => ({
...dataset,
borderColor: createGradient(chart.ctx, chart.chartArea),
fill: 1,
backgroundColor: createGradient(chart.ctx, chart.chartArea). <---- Doesn't add gradient background
}))
};
setChartData(chartData);
}, []);
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
linear-gradient not working in Chrome - Stack Overflow
For instance: background: -webkit-gradient(linear, left top, right top, color-stop(0% ...
Read more >linear-gradient() - CSS: Cascading Style Sheets | MDN
The linear-gradient() CSS function creates an image consisting of a progressive transition between two or more colors along a straight line.
Read more >Background Gradient Not Working - HTML & CSS - SitePoint
Hey Friends! I have been trying to add some gradient to the body of my template and after a couple of goes it...
Read more >CSS Gradients - CSS-Tricks
Gradients are background-image. While declaring the a solid color uses background-color property in CSS, gradients use background-image . This ...
Read more >Setting Backgrounds & Gradients - Learn to Code HTML & CSS
CSS. Background Color; Background Image; Gradient Backgrounds ... Either property will work, and which one you decide to use depends on your preference...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@drydenwilliams Hi.
Legend, thank you @dangreen! Missed that one 😄