Hello I tried to populate Bootstrap cards in a JSP file, but there is this rendering issue with chrome, where card becomes invisible. It works fine in firefox. I have tried inspecting the elements, it was fine. But when I try to scroll down, the card vanishes. Please help me how to resolve this issue.
Here is the Psuedo Code for HTML.
JavaScript
x
39
39
1
<head>
2
<script
3
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"
4
crossorigin="anonymous"></script>
5
</head>
6
<div class="main-cards" id="reports">
7
<%
8
for(int i=0;i<10;i++){
9
%>
10
<div class="card">
11
<div class="card-title">ABC</div>
12
<div class="card-title">XYZ</div>
13
<script>
14
var chart={
15
pass:"10",
16
failed:"4",
17
blocked:"0",
18
skipped:"0",
19
notCompleted:"0",
20
total:"14"
21
}
22
</script>
23
24
<canvas id="<%=i%>" style="height: 180px"></canvas>
25
<script>lineCharts(chart,"<%=i%>");</script>
26
<div class="form-row mb-4">
27
<div class="col">
28
<button class="btn" style="background-color: #3e62bd;color: white" name="details" onclick="window.open('SomeServlet?','details','width=800,height=800')">Details Report</button>
29
</div>
30
<div class="col">
31
<button class="btn" style="background-color: #3e62bd;color: white" name="stability" onclick="window.open('SomeServlet?','stabilty','width=800,height=800')">Stability Report</button>
32
</div>
33
</div>
34
</div>
35
<%
36
}
37
%>
38
</div>
39
and the CSS
JavaScript
1
22
22
1
.main-cards {
2
column-count: 3;
3
column-gap: 20px;
4
margin: 40px;
5
align-items: center;
6
display: block;
7
overflow-x: hidden;
8
}
9
.card {
10
display: flex;
11
flex-direction: column;
12
align-items: center;
13
width: 380px;
14
height: 500px;
15
background-color: white;
16
margin-bottom: 20px;
17
-webkit-column-break-inside: avoid;
18
padding: 24px;
19
box-sizing: border-box;
20
overflow-x: hidden;
21
}
22
JS file:
JavaScript
1
75
75
1
function lineCharts(chart,id){
2
3
var pass = chart.pass;
4
var fail = chart.failed;
5
var blocked = chart.blocked;
6
var NotCompleted = chart.notCompleted;
7
var total = chart.total;
8
var skipped = chart.skipped;
9
10
var legend = [];
11
var TestData = [];
12
var background = [];
13
14
if(total>=0){
15
legend.push("Total");
16
TestData.push(total);
17
background.push("#05a2f7");
18
19
}
20
if(pass>=0){
21
legend.push("Pass");
22
TestData.push(pass);
23
background.push("#70d660");
24
25
}
26
27
if(fail>=0){
28
legend.push("Failed");
29
TestData.push(fail);
30
background.push("#FF5A5E");
31
32
}
33
if(skipped>=0){
34
legend.push("Skipped");
35
TestData.push(skipped);
36
background.push("#bf77d6");
37
38
}
39
if(blocked>0){
40
legend.push("Blocked");
41
TestData.push(blocked);
42
background.push("#f2ca6d");
43
}
44
45
if(NotCompleted>0){
46
legend.push("Not Completed");
47
TestData.push(NotCompleted);
48
background.push("#D3D3D3");
49
}
50
var ctxL = document.getElementById(id).getContext('2d');
51
var myBarChart = new Chart(ctxL, {
52
"type": "horizontalBar",
53
"data": {
54
"labels": legend,
55
"datasets": [{
56
"label": "Pass Fail Details",
57
"data": TestData,
58
"fill": false,
59
"backgroundColor": background,
60
"borderColor": background,
61
"borderWidth": 1
62
}]
63
},
64
"options": {
65
"scales": {
66
"xAxes": [{
67
"ticks": {
68
"beginAtZero": true
69
}
70
}]
71
}
72
}
73
});
74
myBarChart.update();
75
}
Advertisement
Answer
Resolved the issue. Was using different stylesheet of bootstrap before version:
JavaScript
1
2
1
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.15.0/css/mdb.min.css" rel="stylesheet">
2
and changed to
JavaScript
1
2
1
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
2
Now rendering issue is gone and shows correct result.