Chart.defaults.global.legend.display = false;
var ctx = document.getElementById("chart").getContext("2d");
var data = {
labels: ["Januar","Februar","M?rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
datasets: [
{
label: "Test",
type: 'bar',
backgroundColor: "#F29220",
borderColor: "#F29220",
data: [4,1,1,2,2,2,2,2,2,2,2,1]
},
{
label: "Test2",
type: 'bar',
backgroundColor: "#F29220",
borderColor: "#F29220",
data: [4,0,0,0,0,0,0,0,0,0,0,0]
},
{
label: "",
type: 'line',
fillColor: "rgba(220,220,220,0)",
pointColor: "rgba(220,220,220,0)",
borderColor: "#FF0000",
tooltip: false,
data: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
}]
};
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
xAxes: [{
stacked: true,
ticks: {
fontColor: '#000',
}
}],
yAxes: [{
stacked: true,
ticks: {
beginAtZero: true,
fontColor: '#000',
callback: function(label, index, labels) {
return label + '%';
}
},
}]
},
elements: {
point:{
radius: 0
}
},
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
label: function(tooltipItems, data) {
return data.datasets[tooltipItems.datasetIndex].label + ': ' + tooltipItems.yLabel + ' %';
}
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<canvas id="chart" width="740" height="370"></canvas>
See Question&Answers more detail:
os