Skip to content

Instantly share code, notes, and snippets.

@yukikim
Created July 19, 2019 06:14
Show Gist options
  • Save yukikim/d421ea71f7dd5569a447d477e757db15 to your computer and use it in GitHub Desktop.
Save yukikim/d421ea71f7dd5569a447d477e757db15 to your computer and use it in GitHub Desktop.
Test Chart 3
<canvas id="myChart" width="400" height="400"></canvas>
var ctx = document.getElementById('myChart')
var barChartData = {
labels: ['1', '2', '3', '4', '5', '6', '7'],
datasets: [
{
label: 'Dataset 1',
backgroundColor: 'chocolate',
data: [
20,
20,
20,
20,
20,
20,
20
]
},
{
label: 'Dataset 2',
backgroundColor: 'cadetblue',
data: [
20,
20,
20,
20,
20,
20,
12
]
},
{
label: 'Dataset 3',
backgroundColor: 'sandybrown',
data: [
10,
5,
23,
10,
26,
20,
]
}
]
};
myChart = new Chart(ctx, {
type: 'horizontalBar',
data: barChartData,
options: {
title: {
display: true,
text: 'Chart.js Bar Chart - Stacked'
},
//responsive: true,
scales: {
xAxes: [{
stacked: true,
}],
yAxes: [{
stacked: true,
ticks: {
max: 100
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment