Commit 17a768f85a786f38716f1d6863fb4bddcf3213bf

Authored by hitier
1 parent 1b604951

Enhance agent charge tooltip

Showing 1 changed file with 79 additions and 44 deletions   Show diff stats
app/main/templates/agent.html
@@ -18,16 +18,17 @@ @@ -18,16 +18,17 @@
18 18
19 .tooltip { 19 .tooltip {
20 position: absolute; 20 position: absolute;
21 - opacity: 0.8; 21 + opacity: 1.0;
22 z-index: 1000; 22 z-index: 1000;
23 text-align: left; 23 text-align: left;
24 border-radius: 4px; 24 border-radius: 4px;
25 -moz-border-radius: 4px; 25 -moz-border-radius: 4px;
26 -webkit-border-radius: 4px; 26 -webkit-border-radius: 4px;
27 - padding: 8px;  
28 - color: #fff;  
29 - background-color: #000;  
30 - font: 12px sans-serif; 27 + padding: 10px;
  28 + border: 1px solid;
  29 + background-color: white;
  30 + color: black;
  31 + /*font: 12px sans-serif;*/
31 max-width: 300px; 32 max-width: 300px;
32 } 33 }
33 34
@@ -61,21 +62,37 @@ @@ -61,21 +62,37 @@
61 .append("g") 62 .append("g")
62 .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); 63 .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
63 64
64 - const div = d3.select("body").append("div")  
65 - .attr("class", "tooltip")  
66 - .style("opacity", 0);  
67 65
68 // On demande à D3JS de charger notre fichier 66 // On demande à D3JS de charger notre fichier
69 d3.json("{{url_for('main.charge_agent', agent_id=agent.id)}}").then(data => { 67 d3.json("{{url_for('main.charge_agent', agent_id=agent.id)}}").then(data => {
70 68
71 // waiting for structure of the form: 69 // waiting for structure of the form:
72 // 70 //
  71 + // {
  72 + // '2014_S1': {'4Q++': None,
  73 + // 'Activité service C2L': None,
  74 + // 'Activité service COMCL': None,
  75 + // .
  76 + // ...},
  77 + // '2014_S2': {'4Q++': None,
  78 + // 'Activité service C2L': None,
  79 + // .
  80 + // .
  81 + // .
  82 + // '2021_S2': {'4Q++': None,
  83 + // .
  84 + // .
  85 + // 'Test IAS': None,
  86 + // 'cahier des charges DT insu': None,
  87 + // 'ŒIL': None
  88 + // }
  89 + // }
  90 +
  91 +
73 var periods = Object.keys(data) 92 var periods = Object.keys(data)
74 var first_stacked_charges = Object.values(data)[0] 93 var first_stacked_charges = Object.values(data)[0]
75 var projects = Object.keys(first_stacked_charges) 94 var projects = Object.keys(first_stacked_charges)
76 - console.log(projects)  
77 95
78 - // periods = data  
79 var x = d3.scaleBand() 96 var x = d3.scaleBand()
80 .domain(periods) 97 .domain(periods)
81 .range([0, width]) 98 .range([0, width])
@@ -109,33 +126,62 @@ @@ -109,33 +126,62 @@
109 "#800080", 126 "#800080",
110 ]); 127 ]);
111 128
112 - var stack_generator = d3.stack()  
113 - .keys(projects) 129 + var stack_generator = d3.stack().keys(projects)
114 130
  131 + // Building a list of dict, with projects as keys, like in the input dat,
  132 + // but with a new key, 'period' wich value is the period string for that line
  133 + // This is need for the d3js stack_generator function
115 var stackable_data = [] 134 var stackable_data = []
116 - Object.keys(data).forEach( function (period){ 135 + Object.keys(data).forEach(function (period) {
117 line = data[period];