Skip to content

Commit

Permalink
fix($core): Remove hover effect and pointer on non-clickable legends
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mullen committed Nov 8, 2018
1 parent a5fffcf commit dc9a2f2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
11 changes: 6 additions & 5 deletions packages/core/src/base-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ export class BaseChart {
c.selectAll(".legend-btn.active").classed("not-allowed", true);
}

// Add hover effect for legend item circles
self.addLegendCircleHoverEffect();

c.selectAll(".legend-btn").each(function() {
select(this).classed('clickable', true);

select(this).on("click", function() {
c.selectAll(".chart-tooltip").remove();
c.selectAll(".label-tooltip").remove();
Expand Down Expand Up @@ -483,9 +488,6 @@ export class BaseChart {

return "white";
});

// Add hover effect for legend item circles
this.addLegendCircleHoverEffect();
}

positionLegend() {
Expand Down Expand Up @@ -534,7 +536,7 @@ export class BaseChart {
}

addLegendCircleHoverEffect() {
selectAll("li.legend-btn")
this.container.selectAll("li.legend-btn")
.on("mouseover", function() {
const circleRef = select(this).select("div.legend-circle");
const color = (circleRef.node() as HTMLElement).style.backgroundColor.substring(4,
Expand Down Expand Up @@ -707,7 +709,6 @@ export class BaseChart {
})
.style("border-style", Configuration.legend.inactive.borderStyle)
.style("border-width", Configuration.legend.inactive.borderWidth);
this.addLegendCircleHoverEffect();

legendContent.append("text")
.text(d => d.key);
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/pie-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ export class PieChart extends BaseChart {

legend.append("text")
.text(d => d);

this.addLegendCircleHoverEffect();
}

resizeChart() {
Expand Down
34 changes: 19 additions & 15 deletions packages/core/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,25 @@ $default_transition: all .1s ease-out;
font-size: 12px;
margin-bottom: 0;

&:hover {
cursor: pointer;
&.clickable {
&:hover {
cursor: pointer;
}

.legend-circle {
&:hover {
cursor: pointer;
}
}
}

.legend-circle {
display: inherit;
height: 12px;
width: 12px;
border-radius: 3px;
margin: 0 5px 5px 15px;
box-sizing: border-box;
}

span {
Expand All @@ -136,19 +153,6 @@ $default_transition: all .1s ease-out;
display: inherit;
}

.legend-circle {
display: inherit;
height: 12px;
width: 12px;
border-radius: 3px;
margin: 0 5px 5px 15px;
box-sizing: border-box;

&:hover {
cursor: pointer;
}
}

&.not-allowed {
cursor: default;

Expand Down

0 comments on commit dc9a2f2

Please sign in to comment.