Bonjour,

Suite à cette discussion : [SVG] Afficher une Tooltip, je cherche maintenant à personnaliser ce fameux Tooltip.

Je lui ai ajouté une "pointe directionnelle" arrow et c'est celle-ci qui me pose problème.

1) Je ne parviens pas à créer ou simuler une bordure sur mon arrow (before / after), qui ai la même épaisseur que celle du corps du Tooltip.
De plus son comportement est étrange, au move de la souris, l'élément "before" la bordure, semble avoir un décalage / retard par rapport à l'élément "after".

2) Je ne sais pas comment appliquer le "box-shadow" sur mon arrow.

3) Je ne parviens pas à appliquer l'opacité seulement sur mes "background".

J'aimerais que mon Tooltip s'approche de ceci :

Nom : infobulle.PNG
Affichages : 381
Taille : 12,9 Ko

Et voici le code :

Code css : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
body{
	background: #36b0b6;
   }
 
.classTuile {
	width: 250px;
	height: 395px;	
	padding: 6px;
	margin-top: 20px;
	margin-left:20px;
	position: relative;
	background-color: #FFFFFF;
	outline: 1px solid #A0A0A0;		
	outline-offset: -1px;				
	border-radius: 12px;
	color: #000000;
	box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.4);
	/*font-family: "Segoe UI";*/
}
 
.classTitre {
	position: absolute;
	width: 100%;	
	height: 28px;	
	text-align: center;
	font-size: 14px;
	background-color: #3e3e42;
	color: #fff;
	border-radius: 11px 11px 0 0;
	outline: 1px solid #A0A0A0;		
	outline-offset: -1px;					
	margin-left: -6px;
	margin-top: -6px;
	-webkit-border-radius: 11px 11px 0 0;	
	border-bottom: 4px solid #ff0000;
}
 
.classProg {
	position: relative; 
	width: 220px;
	height: 40px;
	top: 8px; 
	margin-left: 10px;	
	margin-top: 8px;
}
.enabledinfobulle {
	cursor: pointer;
  }
 
  .infobulle {
	pointer-events: none;
	position: absolute;
	font-size: 14px;
	text-align: center;
	padding-left: 5px;
	padding-right: 5px;
	z-index: 5;
	min-width: 80px; 
	height: 30px;
	line-height: 30px;
	margin: 0 auto;
	color: #000000;
	border-radius: 5px;
	border: 1px solid #808080;
	box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
    -moz-transform: translateX(-50%);
	-ms-transform: translateX(-50%);
	-webkit-transform: translateX(-50%);
	transform: translateX(-50%);
	display: none;
  }
 
  .infobulle, .background {
    background: #ffffff;
    opacity: 0.8;
  }
 
  .infobulle.active {
	display: block;
  }
 
  .infobulle:after, .infobulle:before {
	content: "";
	position: absolute;
	left: 50%;
	top: 100%;
	width: 0;
	height: 0;
  }	
 
  .infobulle:before {
	margin-left: -12px;
	border-left: 12px solid transparent;
	border-right: 12px solid transparent;
	border-top: 12px solid #808080;
	/* box-shadow: 0px 2px 2px 2px rgba(0, 0, 0, 0.5); */
  }	
 
  .infobulle:after {
	margin-left: -10px;
	border-left: 10px solid transparent;
	border-right: 10px solid transparent;
	border-top: 10px solid #ffffff;
  }

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
 
$jours = array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim");
 
?>
 
<html>
 
<head>
 
    <title><?php echo "TITRE_PAGE";?>
    </title>
 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link href="css/vue.css" rel="stylesheet" type="text/css" media="all">
 
</head>
 
<body>
 
        <div class="classTuile">
            <span class="classTitre"><?php echo "Programmation chauffage";?></span>
            </br>
 
            <svg id="idHeaSch0" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch1" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch2" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch3" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch4" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch5" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
            <svg id="idHeaSch6" class="classProg" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink" width="220" height="40" />
            </br>
         </div>
 
		<div class="infobulle"></div>
 
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
 
    <script type="text/javascript">
 
    var svgNS = "http://www.w3.org/2000/svg";
 
    function createSvgLine(idParent, x1, y1, x2, y2, color) {
        var myLine = document.createElementNS(svgNS, "line");
        myLine.setAttributeNS(null, "x1", x1);
        myLine.setAttributeNS(null, "y1", y1);
        myLine.setAttributeNS(null, "x2", x2);
        myLine.setAttributeNS(null, "y2", y2);
        myLine.setAttributeNS(null, "fill", "none");
        myLine.setAttributeNS(null, "stroke", color);
 
        idParent.appendChild(myLine);
    }
 
    function createSvgText(idParent, x, y, str, size, color, fontname, anchor) {
        var myText = document.createElementNS(svgNS, "text");
        myText.setAttributeNS(null, "x", x);
        myText.setAttributeNS(null, "y", y);
        myText.setAttributeNS(null, "fill", color);
        myText.setAttributeNS(null, "stroke", "none");
        myText.setAttributeNS(null, "font-family", fontname);
        myText.setAttributeNS(null, "font-size", size);
        myText.setAttributeNS(null, "text-anchor", anchor);
        myText.innerHTML = str;
 
        idParent.appendChild(myText);
    }
 
    function createSvgRect(idParent, x1, y1, x2, y2, color, enabled, id) {
        var w = x2 - x1;
        var h = y2 - y1;
        var myRect = document.createElementNS(svgNS, "rect");
        myRect.setAttributeNS(null, "x", x1);
        myRect.setAttributeNS(null, "y", y1);
        myRect.setAttributeNS(null, "width", w);
        myRect.setAttributeNS(null, "height", h);
        myRect.setAttributeNS(null, "fill", color);
        myRect.setAttributeNS(null, "stroke", "none");
        if (enabled) {
            myRect.setAttributeNS(null, "id", id);
            myRect.setAttributeNS(null, "class", "enabledinfobulle");
        }
 
        idParent.appendChild(myRect);
    }
 
    function createSvg(id, prog, title) {
        var idSvg = document.getElementById(id);
 
        while (idSvg.firstChild) {
            idSvg.firstChild.remove()
        }
 
        var gris = "#808080";
        var grisClair = "#C0C0C0";
        var noir = "#000000";
        var bleuclair = "#7cb6ec";
        var orange = "#f7a35c";
        var rouge = "#f45b5b";
 
        var font = "Segoe UI";
        var fontSize = "14";
 
        var titleX = 0;
        var titleY = 30;
 
        var i;
        var str;
        var strY = 12;
        var offsetGauche = 34;
        var offsetDroit = 15;
        var n = Math.floor((220 - offsetGauche - offsetDroit) / 24);
        var taille = n * 24;
 
        for (i = 0; i <= 24; i++) {
            var x = i * n + offsetGauche;
            if ((i % 6) == 0) {
                createSvgLine(idSvg, x, 15, x, 27, gris);
                if (i < 12) {
                    str = '0' + i + ':00';
                } else {
                    str = i + ':00';
                }
                createSvgText(idSvg, x, strY, str, fontSize, gris, font, "middle");
            } else {
                createSvgLine(idSvg, x, 20, x, 27, grisClair);
            }
        }
 
        createSvgText(idSvg, titleX, titleY, title, fontSize, noir, font, "start");
        createSvgRect(idSvg, offsetGauche, 28, taille + offsetGauche, 38, bleuclair, false, "");
 
        if (prog !== '') {
            var progs = prog.split(',');
            n = progs.length;
            if ((n % 3) == 0) {
                for (i = 0; i < n; i += 3) {
                    var mode = progs[i];
                    var start = progs[i + 1];
                    var end = progs[i + 2];
                    nombres = start.split(':');
                    var debut = parseInt(nombres[0]) * 60 + parseInt(nombres[1]);
                    debut = offsetGauche + taille * debut / 1440;
                    nombres = end.split(':');
                    var fin = parseInt(nombres[0]) * 60 + parseInt(nombres[1]);
                    fin = offsetGauche + taille * fin / 1440;
                    if (mode == 'n') {
                        createSvgRect(idSvg, debut, 28, fin, 38, orange, true, start + " " + end);
                    } else {
                        createSvgRect(idSvg, debut, 28, fin, 38, rouge, true, start + " " + end);
                    }
                }
            }
        }
    }
        
        /* n = température normal 20° (orange).
           c = température de confort 21° (rouge).
           bleuclair = pas de programation = température réduite = 19°
        */
           
        var items = ["c,02:30,10:30,n,11:30,16:00",
                                 "n,10:30,17:00",
                                 "n,09:30,18:00",
                                 "n,08:30,19:00",
                                 "n,07:30,20:00",
                                 "n,06:30,21:00",
                                 "n,05:30,22:00"];                               
                                 
                        createSvg("idHeaSch0", items[0], "<?php echo $jours[0];?>")
                        createSvg("idHeaSch1", items[1], "<?php echo $jours[1];?>")
                        createSvg("idHeaSch2", items[2], "<?php echo $jours[2];?>")
                        createSvg("idHeaSch3", items[3], "<?php echo $jours[3];?>")
                        createSvg("idHeaSch4", items[4], "<?php echo $jours[4];?>")
                        createSvg("idHeaSch5", items[5], "<?php echo $jours[5];?>")
                        createSvg("idHeaSch6", items[6], "<?php echo $jours[6];?>")
 
                        $infobulle = $(".infobulle");
 
                        $('.enabledinfobulle').hover(function() {
                            $infobulle.addClass('active');
                            $infobulle.html($(this).attr('id'));
                        }, function() {
                            $infobulle.removeClass('active');
                        });     
    $(document).on('mousemove', function(e) {
        $infobulle.css({
            left: e.pageX ,
            top: e.pageY - 50
        });
    });                                         
 
    </script>		
 
</body>
 
</html>

Pouvez-vous m'aider ?

Bien cordialement