Commit 22397f43b298b8b7913ee86202186bd859c44a44

Authored by hitier
1 parent a5294567

Show tooltip on grouped bar

Showing 1 changed file with 13 additions and 1 deletions   Show diff stats
app/main/static/js/charges.js
... ... @@ -75,6 +75,15 @@ function build_chart(div_selector, data_url, project_name, category) {
75 75 var mouseover = function (e, d) {
76 76 var category_name = d3.select(this.parentNode).datum().key
77 77 var category_charge = d.data[category_name]
  78 + show_tooltip(e, category_name, category_charge)
  79 + }
  80 +
  81 + var mouseovergrouped = function (e, d) {
  82 + var category_name = d.key
  83 + var category_charge = d.value
  84 + show_tooltip(e, category_name, category_charge)
  85 + }
  86 + var show_tooltip = function (e, category_name, category_charge) {
78 87 tooltip
79 88 .transition()
80 89 .duration(200)
... ... @@ -165,7 +174,10 @@ function build_chart(div_selector, data_url, project_name, category) {
165 174 .attr("y", d => yScale(d.value))
166 175 .attr("width", xCategories.bandwidth())
167 176 .attr("height", d => height - yScale(d.value))
168   - .attr("fill", d => colorScale(d.key));
  177 + .attr("fill", d => colorScale(d.key))
  178 + .on("mouseover", mouseovergrouped)
  179 + .on("mousemove", mousemove)
  180 + .on("mouseleave", mouseleave);
169 181  
170 182 }
171 183  
... ...