So I've made this chart.js on my website, but one of my users said: The new bars showing the status for run tests is now too narrow, making it almost impossible to identify which one is hovered over.
How can I make it size better to a 3440x1440 screen, zoom at 100% in Chrome?
Thought about making the css size 80% width, and then no height. So it would fit the page, but then is was a veeeery long graph on a 3440x1440 screen.
.canvasStyle {
height: 400px;
width: 900px;
}
<div class="row justify-content-center">
<div class="canvasStyle">
<canvas id='chart_1' ></canvas>
</div>
</div>
<script>
var TestInformation = <?php echo json_encode($TestInformation); ?>;
var pass = <?php echo json_encode($pass); ?>;
var fail = <?php echo json_encode($fail); ?>;
var error = <?php echo json_encode($error); ?>;
var notrun = <?php echo json_encode($notrun); ?>;
var na = <?php echo json_encode($na); ?>;
var version = <?php echo json_encode($version); ?>;
var title = <?php echo json_encode($title); ?>;
searchId_chart(title, TestInformation, pass, fail, error, notrun, error, na);
</script>
function searchId_chart(title, TestInformation, pass, fail, error, notrun, error, na) {
// Display the array elements
window.onload = function() {
var xValues = TestInformation;
new Chart("chart_1", {
type: 'bar',
data: {
labels: xValues,
datasets: [{
label: 'Passed',
data: pass,
backgroundColor: 'rgb(150,238,144)'
},
{
label: 'Failed',
data: fail,
backgroundColor: 'rgb(204,0,0)'
},
{
label: 'Not Run',
data: notrun,
backgroundColor: 'rgb(0,109,204)'
},
{
label: 'Error',
data: error,
backgroundColor: 'rgb(204,112,0)'
},
{
label: 'NA',
data: na,
backgroundColor: 'rgb(33,33,33)'
}
]
},
options: {
title: {
display: true,
text: title
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
maintainAspectRatio: false,
scales: {
xAxes: [{
stacked: true,
ticks: {
stepSize: 1,
min: 0,
autoSkip: false,
display: false
}
}],
yAxes: [{
stacked: true,
ticks: {
maxTicksLimit: 5,
min: 0,
beginAtZero: true,
userCallback: function(label, index, labels) {
if (Math.floor(label) === label) {
return label;
}
},
}
}]
}
}
});
};
}