Skip to content

Commit

Permalink
Truncate legend name to 18 characters. Use hover to display full lege…
Browse files Browse the repository at this point in the history
…nd name.
  • Loading branch information
dnprock committed Mar 4, 2020
1 parent 33da070 commit 07d94a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/tree/legend/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const LegendItem = ({
transform,
legendRectSize,
legendSpacing,
legendMaxLength,
rectStroke,
rectFill,
label,
Expand All @@ -33,7 +34,8 @@ const LegendItem = ({
y={legendRectSize - legendSpacing}
style={{fontSize: 12, fill: darkGrey, fontFamily: dataFont}}
>
{label}
<title>{label}</title>
{label.substring(0, legendMaxLength)}
</text>
</g>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/legend/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from "react-redux";
import { rgb } from "d3-color";
import LegendItem from "./item";
import { headerFont, darkGrey } from "../../../globalStyles";
import { legendRectSize, legendSpacing, fastTransitionDuration, months } from "../../../util/globals";
import { legendRectSize, legendSpacing, legendMaxLength, fastTransitionDuration, months } from "../../../util/globals";
import { numericToCalendar } from "../../../util/dateHelpers";
import { isColorByGenotype, decodeColorByGenotype } from "../../../util/getGenotype";

Expand Down Expand Up @@ -167,6 +167,7 @@ class Legend extends React.Component {
dispatch={this.props.dispatch}
legendRectSize={legendRectSize}
legendSpacing={legendSpacing}
legendMaxLength={legendMaxLength}
rectFill={rgb(this.props.colorScale.scale(d)).brighter([0.35]).toString()}
rectStroke={rgb(this.props.colorScale.scale(d)).toString()}
transform={this.getTransformationForLegendItem(i)}
Expand Down
1 change: 1 addition & 0 deletions src/util/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const rbsColorDomain = genericDomain;
export const dateColorDomain = genericDomain;
export const legendRectSize = 15;
export const legendSpacing = 4;
export const legendMaxLength = 18;
export const nonTipNodeRadius = 0;
export const tipRadius = 4;
export const tipRadiusOnLegendMatch = 7;
Expand Down

0 comments on commit 07d94a4

Please sign in to comment.