JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.0/dist/chart.min.js"></script>
<canvas width="400" height="170" id="chart"></canvas>
JavaScript
const img = new Image();
img.src = 'https://placeimg.com/640/480/any';
img.onload = function() {
const ctx = document.getElementById('chart').getContext('2d');
const fillPattern = ctx.createPattern(img, 'repeat');
const chart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Item 1', 'Item 2', 'Item 3'],
datasets: [{
data: [90, 80, 90],
backgroundColor: fillPattern
}]
}
});
};