Commit cfc5bded2cfaa338b02905fed0247f356c00e7d9

Authored by hitier
1 parent 207a8628

More chart classes (svg, button)

app/main/static/css/charges.css
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 padding: 0.8em; 45 padding: 0.8em;
46 } 46 }
47 47
48 -.charge_chart svg { 48 +.svg_chart {
49 background-color: #fAfAfA; 49 background-color: #fAfAfA;
50 border: 1pt solid black; 50 border: 1pt solid black;
51 display: inline-block; 51 display: inline-block;
@@ -53,10 +53,11 @@ @@ -53,10 +53,11 @@
53 53
54 text.legend { 54 text.legend {
55 font-size: 12px; 55 font-size: 12px;
  56 + font-family: sans-serif;
56 } 57 }
57 58
58 rect.legend { 59 rect.legend {
59 - stroke: white; 60 + stroke: grey;
60 stroke-width: 0.5pt; 61 stroke-width: 0.5pt;
61 } 62 }
62 63
@@ -87,3 +88,8 @@ rect.bar:hover { @@ -87,3 +88,8 @@ rect.bar:hover {
87 max-width: 300px; 88 max-width: 300px;
88 pointer-events: none; 89 pointer-events: none;
89 } 90 }
  91 +
  92 +button.export {
  93 + float: right;
  94 + margin-right: 0;
  95 +}
90 \ No newline at end of file 96 \ No newline at end of file
app/main/static/js/charges.js
@@ -65,18 +65,19 @@ function build_chart(div_selector, data_url, entity_name, category_type) { @@ -65,18 +65,19 @@ function build_chart(div_selector, data_url, entity_name, category_type) {
65 alert("ALERT ! Every body shall quit the boat, we are sinking ! ALERT !") 65 alert("ALERT ! Every body shall quit the boat, we are sinking ! ALERT !")
66 } 66 }
67 67
  68 + // Create a download button inside the div contaning svg chart
  69 + var dl_btn = d3.select(div_selector).append("button")
  70 + .text('png')
  71 + .attr('class', 'export')
  72 + .on('click', download_png)
  73 +
68 const svg = d3.select(div_selector).append("svg") 74 const svg = d3.select(div_selector).append("svg")
69 - .attr("id", "svg") 75 + .attr("class", "svg_chart")
70 .attr("width", width + margin.left + margin.right) 76 .attr("width", width + margin.left + margin.right)
71 .attr("height", height + margin.top + margin.bottom) 77 .attr("height", height + margin.top + margin.bottom)
72 .append("g") 78 .append("g")
73 .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); 79 .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
74 80
75 - // Create a download button inside the div contaning svg chart  
76 - var dl_btn = d3.select(div_selector).append("button")  
77 - .text('png')  
78 - .on('click', download_png)  
79 -  
80 const tooltip = d3.select('html') 81 const tooltip = d3.select('html')
81 .append("div") 82 .append("div")
82 .style("opacity", 0) 83 .style("opacity", 0)
@@ -158,7 +159,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) { @@ -158,7 +159,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) {
158 .attr('width', legendRectSize) 159 .attr('width', legendRectSize)
159 .attr('height', legendRectSize) 160 .attr('height', legendRectSize)
160 .style('fill', color_scale) 161 .style('fill', color_scale)
161 - .style('stroke', color_scale); 162 + .attr('class', 'legend');
162 163
163 legend.append('text') 164 legend.append('text')
164 .attr('class', 'legend') 165 .attr('class', 'legend')
@@ -393,7 +394,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) { @@ -393,7 +394,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) {
393 394
394 // Draw Xaxis 395 // Draw Xaxis
395 svg.append("g") 396 svg.append("g")
396 - .attr("class", "x axis") 397 + .attr("class", "x_axis")
397 .attr("transform", "translate(0," + height + ")") 398 .attr("transform", "translate(0," + height + ")")
398 .call(xAxis) 399 .call(xAxis)
399 .selectAll("text") 400 .selectAll("text")
@@ -409,7 +410,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) { @@ -409,7 +410,7 @@ function build_chart(div_selector, data_url, entity_name, category_type) {
409 410
410 // Draw Yaxis 411 // Draw Yaxis
411 svg.append("g") 412 svg.append("g")
412 - .attr("class", "y axis") 413 + .attr("class", "y_axis")
413 .call(yAxis) 414 .call(yAxis)
414 415
415 // Draw horizontal lines 416 // Draw horizontal lines