-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisu.html
1074 lines (953 loc) · 41.8 KB
/
visu.html
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>SOFIE 2.0</title>
<link rel="stylesheet" href="app.css">
<link href='https://fonts.googleapis.com/css?family=Bree Serif' rel='stylesheet'>
<link rel="icon" href="img/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/>
<script src="https://d3js.org/d3.v6.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<script src = "js/autocomplete.js"></script>
<script src = "js/libEPCI20.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="crossorigin=""></script>
<script src = "js/leaflet.ajax.min.js"></script>
</head>
<body>
<div class="container" id = "c1">
<nav class="navbar fixed-top navbar-expand-lg">
<div class="container-fluid">
<a id="maintitle" href="index.html">SOFIE</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.html" title="Page d'accueil">Accueil</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="visu.html" title="Diagnostic local">Diagnostic</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="dico.html" title="Dictionnaire de données">Cartes & données</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="apropos.html" title="À propos">À propos</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="help.html" title="Aide">Aide</a>
</li>
</ul>
<!-- <form class="d-flex"> -->
<!-- <input class="form-control me-2" type="search" placeholder="Autre EPCI" aria-label="Search"> -->
<!-- <button class="btn btn-outline-success" type="submit">Chercher</button> -->
<!-- </form> -->
</div>
</div>
</nav>
<div class = "row" id = "form">
<form autocomplete="off" id "form">
<p id = "visu-intro">Entrez le nom de <strong>votre intercommunalité (EPCI / EPT)</strong><br/>pour accéder à un bilan de l'accès à l'emploi des femmes<br/><i>dans votre territoire</i></p>
<div class="autocomplete" style="width:35vw;">
<input type="text" class="form-control" id="myAutocomplete" placeholder="Votre intercommunalité" autocomplete="off">
<br/>
<em><a class = "link" target = "_blank" href = "https://www.observatoire-des-territoires.gouv.fr/outils/cartographie-interactive/#c=indicator&i=_zon_.epci_ept&view=map36"><p<span class = "link-box">Consulter la carte des EPCI / EPT</span></p></a></em>
<input type="submit" value = "On y va !" id = "go" style="float:right;">
</div>
</form>
</div>
</div>
<div class = "container" id = "c2">
<div class = "row">
<div class = "col-12" id = "nomEPCI"></div>
</div>
<div class = "row" id = "mapcontainer">
<div class="col-sm-12">
</div>
</div>
<div class = " visu-dalej">
<div class="col-sm-12 text-center" >
<button type="button" class="btn" id = "visu-dalej-btn" onclick = "dalej()"><i class="bi bi-arrow-down-circle-fill"></i> Voir la suite</button>
<a href = "dico.html" target = "_blank" class = "link"> <span class = "link-box"><i class="bi bi-arrow-right-circle-fill"></i> Comprendre les indicateurs</span></a>
</div>
</div>
</div>
<div class = "container" id = "c3">
<div class = "row">
<div class = "col-12" id = "nomEPCI2"></div>
</div>
<div class="row" id = "row2">
<div class="col-lg-6">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="flexSwitchCheckDisabled">
<label class="form-check-label" for="flexSwitchCheckDisabled"><i class="bi bi-triangle-fill"></i> Hommes</label>
</div>
<div id="dataviz">
</div>
<!-- Accès aide graphique 1 -->
<button type="button" class="btn btn-primary" id = "help-btn-1" data-toggle="modal" data-target="#help-modal-1">
<img class = "legende" src = "img/legende_gr1.png"/>
</button>
<!-- Modal -->
<div class="modal fade" id="help-modal-1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Comment lire ce graphique ?</h5>
<button type="button" class="btn-close" id = "intro-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Dans ce graphique, les valeurs sont standardisées en référence à la valeur nationale pour les femmes qui vaut 100 pour chaque indicateur. La ligne en pointillés représente cette valeur nationale. <strong>Plus les valeurs sont situées à gauche de cette ligne moins le phénomène est marqué</strong> comparativement à la situation des femmes en France ; inversement, <strong>plus les valeurs sont situées à droite de cette ligne et plus la situation est marquée</strong> comparativement à la situation des femmes en France.</p>
<p>Par défaut, les valeurs représentées sous forme de points décrivent la situation des femmes. Il est possible de <strong>comparer</strong> celle-ci <strong>avec la situation des hommes</strong> en activant le petit bouton en haut à droite du graphique. De la même façon que pour les femmes, les valeurs des indicateurs pour les hommes sont standardisées en référence à la valeur nationale pour les femmes qui vaut 100.</p>
<p><em><strong>Attention :</strong> ce graphique permet ainsi de comparer d’une part la situation des femmes localement avec la situation des femmes en France en général et d’autre part la situation des femmes localement avec la situation des hommes localement, mais pas la situation des hommes localement avec la situation des hommes en France en général.</em></p>
<br/>
<p>Pour en savoir plus sur les indicateurs d'insertion professionnelle et de conditions d'emploi, rendez- vous sur le <a href = "dico.html" target = "_blank" class = "link"><span class = "link-box">dictionnaire de données de SOFIE</span></a>.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id = "help-close-1" data-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class = "row" id = "bloccom1">
<div id ="com1">
</div>
</div>
</div>
</div>
<div class = "row visu-dalej">
<div class="col-sm-12 text-center">
<button type="button" class="btn" id = "visu-dalej2-btn" onclick = "dalej2()"><i class="bi bi-arrow-down-circle-fill"></i> Voir la suite</button>
<a href = "dico.html" target = "_blank" class = "link"> <span class = "link-box"><i class="bi bi-arrow-right-circle-fill"></i> Comprendre les indicateurs</span></a>
</div>
</div>
</div>
<div class = "container" id = "c4">
<div class = "row">
<div class = "col-12" id = "nomEPCI3"></div>
</div>
<div class="row" id = "row2">
<div class="col-lg-6">
<div id="dataviz2">
</div>
<!-- Accès aide graphique 2 -->
<button type="button" class="btn btn-primary" id = "help-btn-2" data-toggle="modal" data-target="#help-modal-2">
<img class = "legende" src = "img/legende_gr1.png"/>
</button>
<!-- Modal -->
<div class="modal fade" id="help-modal-2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Comment lire ce graphique ?</h5>
<button type="button" class="btn-close" id = "intro-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Dans ce graphique, les valeurs sont standardisées en référence à la valeur nationale qui vaut 100 pour chaque indicateur. La ligne en pointillés représente cette valeur nationale. <strong>Plus les valeurs sont situées à gauche de cette ligne moins le phénomène est marqué</strong> comparativement à la situation nationale ; inversement, <strong>plus les valeurs sont situées à droite de cette ligne et plus la situation est marquée</strong> comparativement à la situation nationale.</p>
<br/>
<p>Pour en savoir plus sur les indicateurs de freins potentiels, rendez-vous sur le <a href = "dico.html" target = "_blank" class = "link"><span class = "link-box">dictionnaire de données de SOFIE</span></a>.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id = "help-close-2" data-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class = "row" id = "bloccom2">
<div id ="com2">
</div>
</div>
</div>
</div>
<div class = "row visu-dalej">
<div class="col-sm-12 text-center">
<button type="button" class="btn" id = "visu-dalej2-btn" onclick = "changeEPCI()"><i class="bi bi-arrow-up-circle-fill"></i> Voir un autre territoire</button>
<a href = "dico.html" target = "_blank" class = "link"> <span class = "link-box"><i class="bi bi-arrow-right-circle-fill"></i> Comprendre les indicateurs</span></a>
</div>
</div>
</div>
<script>
// initialisation
window.onload = $('html,body').animate({scrollTop: $("#c1").offset().top},100) ;
// set the dimensions and margins of the graph
var margin = {top: 10, right: 30, bottom: 30, left: 30},
width = 560 - margin.left - margin.right,
height = 300 - margin.top - margin.bottom;
// append the svg object to the body of the page
var svg = d3.select("#dataviz")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
var svg2 = d3.select("#dataviz2")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
// Initialisation des variables
var listEPCI = [] ;
var curr_code ;
d3.csv("data/libEPCIEPT20.csv").then(function(libdata){
libdata.forEach(function(d) {
listEPCI.push(d.LIBGEO) ;
}) ;
// Récupérer le code de l'interco sélectionnée
var search ;
$("#form").submit( function(res) {
// Aller à la page de carte
$("#c2").css("display", "block") ;
$('html,body').animate({scrollTop: $("#c2").offset().top},100);
// Récupérer le code associé au nom de l'EPCI sélectionné
search = $('#myAutocomplete').val().replaceAll("'", "'");
console.log(search) ;
var temp = libdata.filter(function(d){ return d.LIBGEO == search}) ;
curr_code = temp[0].CODGEO ;
// Afficher le nom de l'EPCI
$("#nomEPCI").html("<p>"+search+"</p>") ;
$("#nomEPCI2").html("<p>"+search+"</p>") ;
$("#nomEPCI3").html("<p>"+search+"</p>") ;
// Vider les conteneurs svg
svg.selectAll("*").remove();
svg2.selectAll("*").remove();
// CARTE
// Initialisation
var container = document.getElementById('mapcontainer') ;
if(container != null){
container.innerHTML = "<div id='map' style='width: 100%; height: 100%;'>";
container._leaflet_id = null;
}
var mymap = L.map('map');
var match, ipce, ineg, freins ;
// Couleurs
function getColor1(d) {
return d == "FAVP" ? '#40D7A6' :
d == "FAV" ? '#B4E9C7' :
d == "MOY" ? '#FEF8CB' :
d == "DEG" ? '#B58BA5' :
d == "DEGP" ? '#6E2150' :
'#ede9d8';
}
function style1(feature) {
return {
fillColor: getColor1(feature.properties.TYPO_IPCE),
weight: 1,
opacity: 1,
color: 'white',
fillOpacity: 1
};
}
function getColor2(d) {
return d == "Q1" ? '#40D7A6' :
d == "Q2" ? '#B4E9C7' :
d == "Q3" ? '#FEF8CB' :
d == "Q4" ? '#B58BA5' :
d == "Q5" ? '#6E2150' :
'#ede9d8';
}
function style2(feature) {
return {
fillColor: getColor2(feature.properties.TYPO_INEG2),
weight: 1,
opacity: 1,
color: 'white',
fillOpacity: 1
};
}
function getColor3(d) {
return d == "FAVP" ? '#40D7A6' :
d == "FAV" ? '#B4E9C7' :
d == "MOY" ? '#FEF8CB' :
d == "DEG" ? '#B58BA5' :
d == "DEGP" ? '#6E2150' :
'#ede9d8';
}
function style3(feature) {
return {
fillColor: getColor3(feature.properties.TYPO_FREI),
weight: 1,
opacity: 1,
color: 'white',
fillOpacity: 1
};
}
// Paramétrage des infobulles
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
info.update();
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
if(props){
this._div.style.display = "block";
this._div.innerHTML = "<p>"+props.LIB_EPCI_EPT +"</p>";
}
else{
this._div.style.display = "none";
}
};
info.addTo(mymap);
// Comportement au mouseover
function highlightFeature(e) {
layer = e.target ;
info.update(layer.feature.properties);
}
function resetHighlight(e) {
info.update();
}
// Couches d'habillage
var selected, regions, villes, cercles ;
habillage = function(){
// Couches d'habillage
$.getJSON("geo/EPCI_EPT_typogeo.geojson", function(data) {
selected = L.geoJSON(data, {
filter: function(feature, layer) {
return feature.properties.EPCI_EPT == curr_code;
},
style:{
"color": "#666",
"weight": 3,
"fillOpacity": 0,
},
onEachFeature: function(feature, layer){
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
}).addTo(mymap);
}) ;
$.getJSON("geo/reg20.geojson", function(data) {
regions = L.geoJson(data, {
style:{
"color": "#808080",
"weight":1,
"fillColor":"none"
}
}).addTo(mymap)
});
$.getJSON("geo/cercles.geojson", function(data) {
regions = L.geoJson(data, {
style:{
"color": "#808080",
"weight":1,
"fillColor":"none"
}
}).addTo(mymap)
});
$.getJSON("geo/prefreg.geojson", function(data) {
villes = L.geoJson(data, {
pointToLayer: function(feature, latlng) {
return new L.CircleMarker(latlng, {
radius: 5,
fillColor: "#474747",
color: "#FFFFFF",
weight: 2,
opacity: 1,
fillOpacity: 1
});
},
onEachFeature : function(feature, layer){
layer.bindTooltip(function (layer) {
return layer.feature.properties.lib_com;
}, {permanent: true,opacity: 1,
className: 'labels'}
)
}
}).addTo(mymap);
}) ;
}
// Initialisation des légendes
var legende1 = L.control({position: 'bottomright'});
var legende2 = L.control({position: 'bottomright'});
var legende3 = L.control({position: 'bottomright'});
legende1.onAdd = function (map) {
habillage() ;
var div = L.DomUtil.create('div', 'info legend');
div.innerHTML +=
'<img src="img/legende1.png" alt="" width="170" height="200">';
return div;
};
legende2.onAdd = function (map) {
habillage() ;
var div = L.DomUtil.create('div', 'info legend');
div.innerHTML +=
'<img src="img/legende2.png" alt="" width="170" height="200">';
return div;
};
legende3.onAdd = function (map) {
habillage() ;
var div = L.DomUtil.create('div', 'info legend');
div.innerHTML +=
'<img src="img/legende3.png" alt="" width="170" height="200">';
return div;
};
// Carte
$.getJSON("geo/EPCI_EPT_typogeo.geojson", function(data) {
ipce = L.geoJson(data, {
style: style1,
onEachFeature: function(feature, layer){
if(feature.properties.EPCI_EPT == curr_code){
match = layer;
}
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
})
ineg = L.geoJson(data, {
style: style2,
onEachFeature: function(feature, layer){
if(feature.properties.EPCI_EPT == curr_code){
match = layer;
}
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
})
freins = L.geoJson(data, {
style: style3,
onEachFeature: function(feature, layer){
if(feature.properties.EPCI_EPT == curr_code){
match = layer;
}
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
})
ipce.addTo(mymap);
habillage() ;
// Définition de l'emprise à partir de l'EPCI sélectionné
mymap.fitBounds(match.getBounds());
// Menu déroulant
L.control.layers({
"Insertion professionnelle": ipce,
"Inégalités femmes-hommes": ineg,
"Freins potentiels": freins
},null,{collapsed:false}).addTo(mymap);
}) ;
// Légendes
legende1.addTo(mymap);
mymap.on('baselayerchange', function (eventLayer) {
if (eventLayer.name === 'Insertion professionnelle') {
this.removeLayer(regions) ;
this.removeLayer(villes) ;
this.removeLayer(selected) ;
this.removeLayer(ineg) ;
this.removeLayer(freins) ;
this.removeControl(legende2);
this.removeControl(legende3);
legende1.addTo(this);
} else if (eventLayer.name === 'Inégalités femmes-hommes'){
this.removeLayer(regions) ;
this.removeLayer(villes) ;
this.removeLayer(selected) ;
this.removeLayer(ipce) ;
this.removeLayer(freins) ;
this.removeControl(legende1);
this.removeControl(legende3);
legende2.addTo(this);
} else if (eventLayer.name === 'Freins potentiels'){
this.removeLayer(regions) ;
this.removeLayer(villes) ;
this.removeLayer(selected) ;
this.removeLayer(ipce) ;
this.removeLayer(ineg) ;
this.removeControl(legende1);
this.removeControl(legende2);
legende3.addTo(this);
}
});
// GRAPHIQUE 1
// Lire les données
d3.csv("data/sofie_acces_EPT.csv").then(function(data){
data.forEach(function(d) {
d.loc = +d.loc;
d.fra = +d.fra;
d.b100 = +d.b100;
d.diffFH = +d.diffFH;
});
// Définition des variables
// Tableau
data = data.filter(function(d){ return d.EPCI_EPT == curr_code}) ;
dataf = data.filter(function(d){ return d.SEXE == "SEXE2"}) ;
datah = data.filter(function(d){ return d.SEXE == "SEXE1"}) ;
// VISU
drawgraph(data, "F") ;
// Comportement au clic sur le bouton d'affichage des valeurs des hommes
var p = document.getElementById("flexSwitchCheckDisabled") ;
// Visualisation
p.onclick = function () {
if(p.checked){
drawgraph(data, "H") ;
} else {
drawgraph(data, "F") ;
}
}
// Commentaire automatique
var tempfav = dataf.filter(function(d){ return d.b100 < 90}) ;
var tempdeg = dataf.filter(function(d){ return d.b100 > 110}) ;
//var temp = dataf.filter(function(d){ return d.b100 > 125}) ;
var temp2 = dataf.filter(function(d){ return d.b100 == d3.max(dataf, function(d) {return d.b100; })}) ;
var temp3 = data.filter(function(d){ return d.diffFH == d3.max(data, function(d) {return d.diffFH; })}) ;
libindicsup = [] ;
libindicmin = [] ;
for(i in tempdeg){libindicsup.push(" " + tempdeg[i].LIB_VAR_LG.toLowerCase())} ;
for(i in tempfav){libindicmin.push(" " + tempfav[i].LIB_VAR_LG.toLowerCase())} ;
var libindicmax = temp2[0].LIB_VAR_LG ;
var libinegmax = temp3[0].LIB_VAR_LG ;
// Titre
var titre ;
if(dataf[0].TYPO_IPCE == "FAVP"){titre ="Un accès à l'emploi des femmes globalement favorable relativement à la situation nationale"}
if(dataf[0].TYPO_IPCE == "FAV"){titre ="Un accès à l'emploi des femmes plutôt favorable relativement à la situation nationale"}
if(dataf[0].TYPO_IPCE == "MOY"){titre ="Un accès à l'emploi des femmes globalement comparable à la situation nationale"}
if(dataf[0].TYPO_IPCE == "DEG"){titre ="Un accès à l'emploi des femmes plutôt défavorable relativement à la situation nationale"}
if(dataf[0].TYPO_IPCE == "DEGP"){titre ="Un accès à l'emploi des femmes globalement défavorable relativement à la situation nationale"}
$('#com1').html("<h4>"+titre+"</h4>") ;
// Commentaire global
if(tempfav.length == 5){
$('#com1').append("<br/><p class = 'commentaire'>Dans l'EPCI sélectionné, l'ensemble des indicateurs sont significativement plus faibles localement que dans l'ensemble du pays. Pour tous ces indicateurs, la situation est donc sensiblement plus favorable dans le territoire sélectionné qu'en France en général.") ;
}
if(tempfav.length >= 2 & tempfav.length < 5){
$('#com1').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, "+tempfav.length+" indicateurs sont significativement plus faibles localement que dans l'ensemble du pays : <i>"+libindicmin+"</i>. Pour ces indicateurs, la situation est donc sensiblement plus favorable dans le territoire sélectionné qu'en France en général.") ;
}
if(tempfav.length == 1){
$('#com1').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, 1 indicateur est significativement plus faible que la valeur nationale : <i>"+ libindicmin +"</i>. Pour cet indicateur, la situation est donc sensiblement plus favorable dans le territoire sélectionné qu'en France en général.") ;
}
if(tempfav.length == 0){
$('#com1').append("<br/><p class = 'commentaire'>Dans l'EPCI sélectionné, aucun indicateur n'est significativement plus faible localement que dans l'ensemble du pays.") ;
}
if(tempdeg.length == 5){
$('#com1').append("Au contraire, <strong>l'ensemble des indicateurs excèdent significativement la valeur nationale</strong>. Pour tous les indicateurs d'insertion professionnelle et de conditions d'emploi présentés, la situation est donc sensiblement plus dégradée dans le territoire sélectionné que dans l'ensemble du pays. <strong>L'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît comme celui qui marque le plus le territoire </strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
if(tempdeg.length >= 2 & tempdeg.length < 5){
$('#com1').append("Dans le même temps, "+tempdeg.length+" indicateurs excèdent significativement la valeur nationale : <i>"+libindicsup+"</i>. Pour ces indicateurs, la situation est donc sensiblement plus dégradée dans le territoire sélectionné que dans l'ensemble du pays. <strong>L'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît comme celui qui marque le plus le territoire </strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
if(tempdeg.length == 1){
$('#com1').append("Un seul indicateur excède significativement la valeur nationale. <strong>L'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît de fait comme celui qui marque le plus le territoire</strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
if(tempdeg.length == 0){
$('#com1').append("<strong>Aucun indicateur n'excède significativement la valeur nationale.</strong>") ;
}
// Commentaire inégalités
if(dataf[0].TYPO_INEG2 == "Q1"){
$('#com1').append("<br/><br/><strong>Les inégalités entre les femmes et les hommes</strong> en matière d'accès à l'emploi et de conditions de travail <strong>sont globalement contenues dans le territoire sélectionné relativement à ce qu'on observe dans l'ensemble du pays.</strong> L'indicateur <i>"+ libinegmax.toLowerCase()+"</i> est celui pour lequel les inégalités entre les femmes et les hommes sont le plus marquées avec une valeur de "+Math.round(temp3[1].loc * 10) / 10+" "+temp2[0].Unite+" pour les femmes contre "+Math.round(temp3[0].loc * 10) / 10+" "+temp2[0].Unite+" pour les hommes.</p>") ;
}
else if (dataf[0].TYPO_INEG2 == "Q2"){
$('#com1').append("<br/><br/><strong>Les inégalités entre les femmes et les hommes</strong> en matière d'accès à l'emploi et de conditions de travail dans le territoire sélectionné <strong>sont plutôt contenues dans le territoire sélectionné relativement à ce qu'on observe dans l'ensemble du pays.</strong> L'indicateur <i>"+ libinegmax.toLowerCase()+"</i> est celui pour lequel les inégalités entre les femmes et les hommes sont le plus marquées avec une valeur de "+Math.round(temp3[1].loc * 10) / 10+" "+temp2[0].Unite+" pour les femmes contre "+Math.round(temp3[0].loc * 10) / 10+" "+temp2[0].Unite+" pour les hommes.</p>") ;
}
else if (dataf[0].TYPO_INEG2 == "Q3"){
$('#com1').append("<br/><br/><strong>Les inégalités entre les femmes et les hommes</strong> en matière d'accès à l'emploi et de conditions de travail dans le territoire sélectionné <strong>sont globalement comparables à ce qu'on observe dans l'ensemble du pays.</strong> L'indicateur <i>"+ libinegmax.toLowerCase()+"</i> est celui pour lequel les inégalités entre les femmes et les hommes sont le plus marquées avec une valeur de "+Math.round(temp3[1].loc * 10) / 10+" "+temp2[0].Unite+" pour les femmes contre "+Math.round(temp3[0].loc * 10) / 10+" "+temp2[0].Unite+" pour les hommes.</p>") ;
}
else if (dataf[0].TYPO_INEG2 == "Q4"){
$('#com1').append("<br/><br/><strong>Les inégalités entre les femmes et les hommes</strong> en matière d'accès à l'emploi et de conditions de travail <strong>sont globalement plus marquées dans le territoire sélectionné relativement à ce qu'on observe dans l'ensemble du pays.</strong> L'indicateur <i>"+ libinegmax.toLowerCase()+"</i> est celui pour lequel les inégalités entre les femmes et les hommes sont le plus marquées avec une valeur de "+Math.round(temp3[1].loc * 10) / 10+" "+temp2[0].Unite+" pour les femmes contre "+Math.round(temp3[0].loc * 10) / 10+" "+temp2[0].Unite+" pour les hommes.</p>") ;
}
else if (dataf[0].TYPO_INEG2 == "Q5"){
$('#com1').append("<br/><br/><strong>Les inégalités entre les femmes et les hommes</strong> en matière d'accès à l'emploi et de conditions de travail <strong>sont significativement plus marquées dans le territoire sélectionné relativement à ce qu'on observe dans l'ensemble du pays.</strong> L'indicateur <i>"+ libinegmax.toLowerCase()+"</i> est celui pour lequel les inégalités entre les femmes et les hommes sont le plus marquées avec une valeur de "+Math.round(temp3[1].loc * 10) / 10+" "+temp2[0].Unite+" pour les femmes contre "+Math.round(temp3[0].loc * 10) / 10+" "+temp2[0].Unite+" pour les hommes.</p>") ;
}
});
// GRAPHIQUE 2
// Lire les données
d3.csv("data/sofie_freins_EPT.csv").then(function(data){
data.forEach(function(d) {
d.loc = +d.loc;
d.fra = +d.fra;
d.b100 = +d.b100;
});
// Définition des variables
// Tableau
data = data.filter(function(d){ return d.EPCI_EPT == curr_code}) ;
// VISU
drawgraph2(data) ;
// Commentaire automatique
var temp = data.filter(function(d){ return d.b100 > 110}) ;
var temp2 = data.filter(function(d){ return d.b100 == d3.max(data, function(d) {return d.b100; })}) ;
libindicsup = [] ;
for(i in temp){libindicsup.push(" " + temp[i].LIB_VAR_LG.toLowerCase())} ;
var libindicmax = temp2[0].LIB_VAR_LG ;
// Titre
var titre ;
if(data[0].TYPO_FREI == "DEGP"){titre ="Des freins potentiels à l'emploi des femmes marqués"}
if(data[0].TYPO_FREI == "DEG"){titre ="Des freins potentiels à l'emploi des femmes plutôt marqués"}
if(data[0].TYPO_FREI == "MOY"){titre ="Des freins potentiels à l'emploi des femmes proche de la moyenne ou d'intensités variables"}
if(data[0].TYPO_FREI == "FAV"){titre ="Des freins potentiels à l'emploi des femmes plutôt limités"}
if(data[0].TYPO_FREI == "FAVP"){titre ="Des freins potentiels à l'emploi des femmes limités"}
$('#com2').html("<h4>"+titre+"</h4>") ;
// Commentaire global
if(temp.length == 5){
$('#com2').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, l'ensemble des indicateurs de freins potentiels à l'accès à l'emploi des femmes excèdent significativement la valeur nationale.<br/><br/>Parmi les freins potentiels étudiés, <strong>l'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît comme le principal frein potentiel à l'accès à l'emploi des femmes dans ce territoire </strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
else if(temp.length > 1){
$('#com2').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, "+temp.length+" indicateurs de freins potentiels à l'accès à l'emploi des femmes excèdent significativement la valeur nationale : <i>"+libindicsup+"</i>. Ces freins potentiels à l'accès à l'emploi des femmes sont donc sensiblement plus marqués dans le territoire sélectionné que dans l'ensemble du pays.<br/><br/>Parmi les freins potentiels étudiés, <strong>l'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît comme le principal frein potentiel à l'accès à l'emploi des femmes dans ce territoire </strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
else if(temp.length == 1){
$('#com2').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, 1 indicateur de freins potentiels à l'accès à l'emploi excède significativement la valeur nationale. <br/><br/>Parmi les freins potentiels étudiés, <strong>l'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît de fait comme le principal frein potentiel à l'accès à l'emploi des femmes dans ce territoire</strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
else if(temp.length == 0){
$('#com2').append("<br/><p class = 'commentaire'>Dans l’EPCI sélectionné, aucun indicateur de freins potentiels à l'accès à l'emploi n'excède significativement la valeur nationale. <br/><br/>Parmi les freins potentiels étudiés, <strong>l'indicateur <i>"+ libindicmax.toLowerCase() +"</i> apparaît néanmoins comme le principal frein potentiel à l'accès à l'emploi des femmes dans ce territoire</strong> avec une valeur de "+Math.round(temp2[0].loc * 10) / 10+" "+temp2[0].Unite+" contre "+Math.round(temp2[0].fra * 10) / 10+" "+temp2[0].Unite+" en France.") ;
}
});
return false ;
});
});
// Menu autocomplétion
const field = document.getElementById('myAutocomplete');
const ac = new Autocomplete(field, {
data: listEPCI2,
maximumItems: 5
});
// Fonction graphique
function drawgraph(dfG, sexe){
if(sexe == "F"){
dfsexe = dataf ;
vmin = d3.min(dfsexe, function(d) {return d.b100; });
vmax = d3.max(dfsexe, function(d) {return d.b100; });
// Remettre à 0 le switch button des hommes
document.querySelector("#flexSwitchCheckDisabled").checked = false ;
} else if (sexe == "H"){
dfsexe = datah ;
vmin = d3.min(dfG, function(d) {return d.b100; }) ;
vmax = d3.max(dfG, function(d) {return d.b100; }) ;
}
// Initialisation
svg.selectAll("*").remove();
// Define the div for the tooltip
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Add X axis
// On fait en sorte que l'axe France soit toujours présent
if(vmin > 100){vmin = 100} ;
if(vmax < 100){vmax = 100} ;
var x = d3.scaleLinear()
//.domain(dfsexe.map(function(d) { return d.b100; }))
.domain([vmin, vmax])
.range([ 100, width]);
<!-- svg.append("g") -->
<!-- .attr("transform", "translate(0," + height + ")") -->
<!-- .call(d3.axisBottom(x)); -->
// Y axis
var y = d3.scaleBand()
.range([0, height])
.domain(dfG.map(function(d) { return d.LIB_VAR_SH; }))
.padding(1);
svg.append("g")
.attr("transform", "translate(100, 0)")
.call(d3.axisLeft(y))
.select(".domain").remove();
//svg.attr("transform", "translate(" + Math.max(margin.left, 120) + "," + margin.top + ")");
// Rectangles
// Bornes particulières
var binf2 ;
if(vmin > 75){binf2 = vmin ;} else {binf2 = 75 ;}
var binf3 ;
if(vmin > 90){binf3 = vmin ;} else {binf3 = 90 ;}
var binf4 ;
if(vmin > 110){binf4 = vmin ;} else {binf4 = 110 ;}
var binf5 ;
if(vmin > 125){binf5 = vmin ;} else {binf5 = 125 ;}
var nodes = svg.selectAll(".rect")
.data(dfsexe)
.enter()
//.append("g")
//.classed('rect', true)
if(vmin < 75){
nodes.append("rect")
.attr("x", x(vmin)).attr("y", y(1))
.attr("width", x(binf2)-x(vmin)).attr("height", height)
.attr("fill", "#40D7A6") ;
}
if(vmin < 90){
nodes.append("rect")
.attr("x", x(binf2)).attr("y", y(0))
.attr("width", x(binf3)-x(binf2)).attr("height", height)
.attr("fill", "#B4E9C7") ;
}
nodes.append("rect")
.attr("x", x(binf3)).attr("y", y(0))
.attr("width", x(binf4)-x(binf3)).attr("height", height)
.attr("fill", "#FEF8CB") ;
if(vmax > 110){
nodes.append("rect")
.attr("x", x(binf4)).attr("y", y(0))
.attr("width", x(binf5)-x(binf4)).attr("height", height)
.attr("fill", "#B58BA5") ;
}
if(vmax > 125){
nodes.append("rect")
.attr("x", x(binf5)).attr("y", y(0))
.attr("width", width-x(binf5)+30).attr("height", height)
.attr("fill", "#6E2150") ;
}
// Lignes horizontales
svg.selectAll("myline")
.data(dfG)
.enter()
.append("line")
//.attr("x1", vmin+50)
.attr("x1", function(d) { return x(vmin); })
.attr("x2", function(d) { return x(vmax)+30; })
.attr("y1", function(d) { return y(d.LIB_VAR_SH); })
.attr("y2", function(d) { return y(d.LIB_VAR_SH); })
.attr("stroke", "white")
.attr("stroke-width", "1px") ;
// Ligne base 100
svg.selectAll("base100")
.data(dfG)
.enter()
.append("line")
.attr("x1", x(100))
.attr("y2", 0)
.attr("x2", x(100))
.attr("y2", height)
.style("stroke-dasharray", ("3, 3"))
.attr("stroke", "#808080") ;
// Symboles
if(sexe == "F"){
svg.selectAll("mycircle")
.data(dfsexe)
.enter()
.append("circle")
.attr("cx", function(d) { return x(d.b100); })
.attr("cy", function(d) { return y(d.LIB_VAR_SH); })
.attr("r", "6")
.style("fill", "black")
.on("mouseover", function(event,d) {
div.transition()
.duration(200)
.style("opacity", .9);
div.html(d.LIB_VAR_LG + " (femmes) :<br/><strong>" + Math.round(d.loc * 10) / 10 + " %</strong><br/><br/><i>France : " + Math.round(d.fra * 10) / 10 + " %</i>")
.style("left", (event.pageX) + 15 + "px")
.style("top", (event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(500)
.style("opacity", 0);
});
}
else if (sexe == "H"){
svg.selectAll("mycircle")
.data(dataf)
.enter()
.append("circle")
.attr("cx", function(d) { return x(d.b100); })
.attr("cy", function(d) { return y(d.LIB_VAR_SH); })
.attr("r", "6")
.style("fill", "black")
.on("mouseover", function(event,d) {
div.transition()
.duration(200)
.style("opacity", .9);
div.html(d.LIB_VAR_LG + " (femmes) :<br/><strong>" + Math.round(d.loc * 10) / 10 + " %</strong><br/><br/><i>France (femmes) : " + Math.round(d.fras * 10) / 10 + " %</i>")
.style("left", (event.pageX) + 15 + "px")
.style("top", (event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(500)
.style("opacity", 0);
});
var triangleSize = 75;
var triangle = d3.symbol()
.type(d3.symbolTriangle)
.size(triangleSize) ;
svg.selectAll("mytriangle")
.data(datah)
.enter()
.append("path")
.attr('d', triangle)
.attr("class", "crclh")
.attr("transform", function(d) { return "translate(" + x(d.b100) + "," + y(d.LIB_VAR_SH) + ")"; })
.style("fill", "black")
.on("mouseover", function(event,d) {
div.transition()
.duration(200)
.style("opacity", .9);
div.html(d.LIB_VAR_LG + " (hommes) :<br/><strong>" + Math.round(d.loc * 10) / 10 + " %</strong><br/><br/><i>France (hommes) : " + Math.round(d.fras * 10) / 10 + " %</i>")
.style("left", (event.pageX) + 15 + "px")
.style("top", (event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(500)
.style("opacity", 0);
});
}
}
// Graphique freins
function drawgraph2(dfG){
// Initialisation
svg2.selectAll("*").remove();
vmin = d3.min(dfG, function(d) {return d.b100; });
vmax = d3.max(dfG, function(d) {return d.b100; });
// Define the div for the tooltip
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Add X axis
// On fait en sorte que l'axe France soit toujours présent
if(vmin > 100){vmin = 100} ;
if(vmax < 100){vmax = 100} ;
var x = d3.scaleLinear()
//.domain(dfG.map(function(d) { return d.b100; }))
.domain([vmin, vmax])
.range([ 150, width]);
<!-- svg2.append("g") -->
<!-- .attr("transform", "translate(0," + height + ")") -->
<!-- .call(d3.axisBottom(x)); -->
// Y axis
var y = d3.scaleBand()
.range([0, height])
.domain(dfG.map(function(d) { return d.LIB_VAR_SH; }))
.padding(1);
svg2.append("g")
.attr("transform", "translate(150, 0)")
.call(d3.axisLeft(y))
.select(".domain").remove();
//svg2.attr("transform", "translate(" + Math.max(margin.left, 120) + "," + margin.top + ")");
// Rectangles
// Bornes particulières
var binf2 ;
if(vmin > 75){binf2 = vmin ;} else {binf2 = 75 ;}
var binf3 ;
if(vmin > 90){binf3 = vmin ;} else {binf3 = 90 ;}
var binf4 ;
if(vmin > 110){binf4 = vmin ;} else {binf4 = 110 ;}
var binf5 ;
if(vmin > 125){binf5 = vmin ;} else {binf5 = 125 ;}
var nodes = svg2.selectAll(".rect")
.data(dfG)
.enter()
//.append("g")
//.classed('rect', true)
if(vmin < 75){
nodes.append("rect")
.attr("x", x(vmin)).attr("y", y(1))
.attr("width", x(binf2)-x(vmin)).attr("height", height)
.attr("fill", "#40D7A6") ;
}
if(vmin < 90){
nodes.append("rect")
.attr("x", x(binf2)).attr("y", y(0))
.attr("width", x(binf3)-x(binf2)).attr("height", height)
.attr("fill", "#B4E9C7") ;
}
nodes.append("rect")
.attr("x", x(binf3)).attr("y", y(0))
.attr("width", x(binf4)-x(binf3)).attr("height", height)
.attr("fill", "#FEF8CB") ;
if(vmax > 110){
nodes.append("rect")
.attr("x", x(binf4)).attr("y", y(0))
.attr("width", x(binf5)-x(binf4)).attr("height", height)
.attr("fill", "#B58BA5") ;
}
if(vmax > 125){
nodes.append("rect")
.attr("x", x(binf5)).attr("y", y(0))
.attr("width", width-x(binf5)+30).attr("height", height)
.attr("fill", "#6E2150") ;
}
// Lignes horizontales
svg2.selectAll("myline")
.data(dfG)
.enter()
.append("line")
//.attr("x1", vmin+50)
.attr("x1", function(d) { return x(vmin); })
.attr("x2", function(d) { return x(vmax)+30; })
.attr("y1", function(d) { return y(d.LIB_VAR_SH); })
.attr("y2", function(d) { return y(d.LIB_VAR_SH); })
.attr("stroke", "white")
.attr("stroke-width", "1px") ;
// Ligne base 100
svg2.selectAll("base100")
.data(dfG)
.enter()