Commit 5a28a9b82ab44249578e72a96ffdc15dbbbd6b04
1 parent
7ba07d51
Exists in
master
and in
3 other branches
modified something for test
Showing
1 changed file
with
33 additions
and
7 deletions
Show diff stats
amadeus/static/js/charts/home.js
| ... | ... | @@ -233,7 +233,7 @@ var charts = { |
| 233 | 233 | |
| 234 | 234 | most_accessed_subjects: function(url){ |
| 235 | 235 | $.get(url, function(dataset){ |
| 236 | - var width = 400; | |
| 236 | + var width = 1000; | |
| 237 | 237 | var height = 300; |
| 238 | 238 | |
| 239 | 239 | var new_div = d3.select(".carousel-inner").append("div").attr("class","item"); |
| ... | ... | @@ -242,22 +242,48 @@ var charts = { |
| 242 | 242 | .style("margin","auto") |
| 243 | 243 | .style("display","block"); |
| 244 | 244 | |
| 245 | - svg.selectAll("rect") | |
| 245 | + var barPadding = 5 | |
| 246 | + var bottomPadding = 15; | |
| 247 | + var padding = 30; | |
| 248 | + var yScale = d3.scaleLinear() | |
| 249 | + .domain([0, d3.max(dataset, function(d) { return d.count; })]) | |
| 250 | + .range([bottomPadding, 300]); | |
| 251 | + | |
| 252 | + var rects = svg.selectAll("rect") | |
| 246 | 253 | .data(dataset) |
| 247 | 254 | .enter() |
| 248 | 255 | .append("rect") |
| 249 | 256 | .attr("x", function(d, i){ |
| 250 | - return i * (width / dataset.length - 1 ); | |
| 257 | + return i * (width / dataset.length ) + barPadding ; | |
| 251 | 258 | }) |
| 252 | 259 | .attr("y", function(d){ |
| 253 | - return height - d.count*2; | |
| 260 | + return height - d.count - bottomPadding; | |
| 254 | 261 | }) |
| 255 | - .attr("width", 20) | |
| 262 | + .attr("width", | |
| 263 | + width / dataset.length - barPadding | |
| 264 | + ) | |
| 256 | 265 | .attr("height", function(d){ |
| 257 | - return d.count*2; | |
| 266 | + return yScale(d.count); | |
| 258 | 267 | }); |
| 259 | 268 | |
| 260 | - | |
| 269 | + rects.on("mouseover", function(d){ | |
| 270 | + $(this).attr("fill", "red"); | |
| 271 | + }); | |
| 272 | + | |
| 273 | + rects.on("mouseout", function(d){ | |
| 274 | + $(this).attr("fill", "black"); | |
| 275 | + }); | |
| 276 | + | |
| 277 | + svg.append("text") | |
| 278 | + .attr("x", width/2) | |
| 279 | + .attr("y", 20) | |
| 280 | + .attr("text-anchor", "middle") | |
| 281 | + .style("font-size", "30px") | |
| 282 | + .text("Subjects mais acessados") | |
| 283 | + .attr("fill", "#003333") | |
| 284 | + .style("font-weight", "bold") | |
| 285 | + .style("font-style", "italic"); | |
| 286 | + | |
| 261 | 287 | }); |
| 262 | 288 | } |
| 263 | 289 | } | ... | ... |