Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 62e90a5

Browse files
authored
Update legend icons size (#299)
1 parent c2dee17 commit 62e90a5

File tree

654 files changed

+76
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

654 files changed

+76
-17
lines changed

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@
144144
"wdio-default": "terra wdio",
145145
"wdio-lowlight": "NODE_OPTIONS=--max-old-space-size=2048 terra wdio --themes clinical-lowlight-theme",
146146
"wdio-fusion": "terra wdio --themes orion-fusion-theme",
147-
"wdio": "terra wdio --themes terra-default-theme"
147+
"wdio": "terra wdio --themes terra-default-theme",
148+
"wdio:bar": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/BarGraph/bar-graph-spec.js",
149+
"wdio:bubble": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/BubbleGraph/bubbleGraphs-spec.js",
150+
"wdio:combination": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/CombinationGraph/combination-graph-spec.js",
151+
"wdio:gantt": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/GanttChart/gantt-chart-spec.js",
152+
"wdio:general": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/General/general-spec.js",
153+
"wdio:line": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/LineGraph/line-graph-spec.js",
154+
"wdio:pairedresult": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/PairedResultGraph/paired-result-graph-spec.js",
155+
"wdio:pie": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/PieChart/pie-graph-spec.js",
156+
"wdio:scatter": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/ScatterGraph/scatter-graph-spec.js",
157+
"wdio:timeline": "terra wdio --themes terra-default-theme --spec packages/terra-graphs/tests/wdio/Graphs/Timeline/timeline-spec.js"
148158
}
149159
}

packages/carbon-graphs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions

packages/carbon-graphs/src/js/helpers/legend.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ const legendDisplayStyle = (input) => (input.legendOptions
6565
*/
6666
const createLegendIcon = (buttonPath, input) => buttonPath.append(() => new Shape(getShapeForTarget(input)).getShapeElement(
6767
getDefaultSVGProps({
68-
svgClassNames: styles.legendItemIcon,
68+
svgClassNames: (input.legendOptions && input.legendOptions.showLine)
69+
? styles.legendItemIconWithLine
70+
: styles.legendItemIcon,
6971
svgStyles: `fill: ${getColorForTarget(input)};`,
7072
}),
7173
true,
@@ -75,14 +77,13 @@ const createLegendIcon = (buttonPath, input) => buttonPath.append(() => new Shap
7577
*
7678
* @private
7779
* @param {object} buttonPath - d3 svg object
78-
* @param {object} t - input item object processed from the input JSON
80+
* @param {object} input - input item object processed from the input JSON
7981
*/
80-
const createLegendLine = (buttonPath, t) => {
81-
const { legendOptions } = t;
82+
const createLegendLine = (buttonPath, input) => {
8283
const svg = buttonPath
8384
.append('svg')
8485
.classed(
85-
legendOptions.showShape
86+
input.legendOptions.showShape
8687
? styles.legendItemLineWithIcon
8788
: styles.legendItemLine,
8889
true,
@@ -94,16 +95,16 @@ const createLegendLine = (buttonPath, t) => {
9495
.attr('x1', 1)
9596
.attr(
9697
'x2',
97-
legendOptions.showShape
98+
input.legendOptions.showShape
9899
? constants.DEFAULT_LEGEND_LINE_WIDTH_WITH_SYMBOL - 1
99100
: constants.DEFAULT_LEGEND_LINE_WIDTH - 1,
100101
)
101102
.attr('y1', constants.LEGEND_LINE_POSITION)
102103
.attr('y2', constants.LEGEND_LINE_POSITION)
103104
.attr(
104105
'style',
105-
`stroke: ${getColorForTarget(t)};
106-
stroke-dasharray: ${legendOptions.style.strokeDashArray};
106+
`stroke: ${getColorForTarget(input)};
107+
stroke-dasharray: ${input.legendOptions.style.strokeDashArray};
107108
stroke-width: 1px;`,
108109
);
109110
};
@@ -117,10 +118,8 @@ const createLegendLine = (buttonPath, t) => {
117118
const processLegendOptions = (buttonPath, input) => {
118119
if (input.legendOptions) {
119120
// Create a legend icon only if the showShape is true
120-
if (input.showShapes || input.showShapes === undefined) {
121-
if (input.legendOptions.showShape) {
122-
createLegendIcon(buttonPath, input);
123-
}
121+
if ((input.showShapes || input.showShapes === undefined) && input.legendOptions.showShape) {
122+
createLegendIcon(buttonPath, input);
124123
}
125124
if (input.legendOptions.showLine) {
126125
createLegendLine(buttonPath, input);

packages/carbon-graphs/src/js/helpers/styles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default {
3939
legendItem: 'carbon-legend-item',
4040
legendItemBtn: 'carbon-legend-item-btn',
4141
legendItemIcon: 'carbon-legend-item-icon',
42+
legendItemIconWithLine: 'carbon-legend-item-icon-with-line',
4243
legendItemLine: 'carbon-legend-item-line',
4344
legendItemLineWithIcon: 'carbon-legend-item-line-with-icon',
4445
legendItemSpan: 'carbon-legend-item-span',

packages/carbon-graphs/src/less/core.less

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ svg:not(:root) {
77
}
88

99
.carbon-svg-icon {
10+
1011
width: 0.625rem;
1112
height: 0.625rem;
1213
display: inline-block;
@@ -151,8 +152,20 @@ svg:not(:root) {
151152
}
152153
}
153154

155+
// refers to the icon itself IF there is no line next to it
154156
& .carbon-legend-item-icon {
155157
display: block;
158+
height: 0.857rem;
159+
width: 0.857rem;
160+
stroke: @white;
161+
stroke-width: 5px;
162+
}
163+
164+
// refers to the icon IF there is a line next to it
165+
& .carbon-legend-item-icon-with-line {
166+
display: block;
167+
height: 0.625rem;
168+
width: 0.625rem;
156169
stroke: @white;
157170
stroke-width: 5px;
158171
}
@@ -164,12 +177,14 @@ svg:not(:root) {
164177
align-items: center;
165178
}
166179

180+
// refers to the line itself IF there is no icon next to it
167181
& .carbon-legend-item-line {
168182
height: 5px;
169183
width: 28px;
170184
padding-top: 1px;
171185
}
172186

187+
// refers to the line IF there is an icon next to it
173188
& .carbon-legend-item-line-with-icon {
174189
height: 5px;
175190
width: 18px;

packages/carbon-graphs/tests/unit/controls/Line/LineLoad-spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ describe('Line - Load', () => {
11041104
expect(iconPath.getAttribute('d')).not.toBeNull();
11051105
});
11061106
describe('when showShapes is true', () => {
1107-
it('loads shape and line if user sets showLine to be true and showShape to be true', () => {
1107+
it('loads shape and line if user sets showLine to be true and showShape to be true', () => {
11081108
const input = getInput(valuesDefault, false, false);
11091109
input.legendOptions = {
11101110
showShape: true,
@@ -1121,7 +1121,7 @@ describe('Line - Load', () => {
11211121
expect(SVGElements.length).toBe(2);
11221122

11231123
expect(iconSVG).not.toBeNull();
1124-
expect(iconSVG.classList).toContain(styles.legendItemIcon);
1124+
expect(iconSVG.classList).toContain(styles.legendItemIconWithLine);
11251125
expect(iconPath).not.toBeNull();
11261126
expect(iconPath.getAttribute('d')).not.toBeNull();
11271127

@@ -1154,7 +1154,7 @@ describe('Line - Load', () => {
11541154
expect(SVGElements.length).toBe(2);
11551155

11561156
expect(iconSVG).not.toBeNull();
1157-
expect(iconSVG.classList).toContain(styles.legendItemIcon);
1157+
expect(iconSVG.classList).toContain(styles.legendItemIconWithLine);
11581158
expect(iconPath).not.toBeNull();
11591159
expect(iconPath.getAttribute('d')).not.toBeNull();
11601160

packages/carbon-graphs/tests/unit/controls/PairedResult/PairedResultLoad-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ describe('Paired Result - Load', () => {
15331533
const lineSVG = svgElements[1];
15341534
expect(svgElements.length).toBe(2);
15351535
expect(iconSVG).not.toBeNull();
1536-
expect(iconSVG.classList).toContain(styles.legendItemIcon);
1536+
expect(iconSVG.classList).toContain(styles.legendItemIconWithLine);
15371537
expect(lineSVG).not.toBeNull();
15381538
expect(lineSVG.classList).toContain(
15391539
styles.legendItemLineWithIcon,

packages/terra-graphs-docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions

packages/terra-graphs-docs/src/terra-graphs-src/components/Graph.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,22 @@
147147
}
148148
}
149149

150+
// refers to the icon itself IF there is no line next to it
150151
.carbon-legend-item-icon {
151152
display: block;
153+
height: 0.857rem;
152154
stroke: var(--terra-graphs-white);
153155
stroke-width: 5px;
156+
width: 0.857rem;
157+
}
158+
159+
// refers to the icon IF there is a line next to it
160+
.carbon-legend-item-icon-with-line {
161+
display: block;
162+
height: 0.857rem;
163+
stroke: var(--terra-graphs-white);
164+
stroke-width: 5px;
165+
width: 0.857rem;
154166
}
155167

156168
.carbon-legend-item-span {
@@ -160,12 +172,14 @@
160172
justify-content: center;
161173
}
162174

175+
// refers to the line itself IF there is no icon next to it
163176
.carbon-legend-item-line {
164177
height: 5px;
165178
padding-top: 1px;
166179
width: 28px;
167180
}
168181

182+
// refers to the line IF there is an icon next to it
169183
.carbon-legend-item-line-with-icon {
170184
height: 5px;
171185
padding-top: 1px;

packages/terra-graphs/src/components/Graph.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,22 @@
147147
}
148148
}
149149

150+
// refers to the icon itself IF there is no line next to it
150151
.carbon-legend-item-icon {
151152
display: block;
153+
height: 0.857rem;
152154
stroke: var(--terra-graphs-white);
153155
stroke-width: 5px;
156+
width: 0.857rem;
157+
}
158+
159+
// refers to the icon IF there is a line next to it
160+
.carbon-legend-item-icon-with-line {
161+
display: block;
162+
height: 0.857rem;
163+
stroke: var(--terra-graphs-white);
164+
stroke-width: 5px;
165+
width: 0.857rem;
154166
}
155167

156168
.carbon-legend-item-span {
@@ -160,12 +172,14 @@
160172
justify-content: center;
161173
}
162174

175+
// refers to the line itself IF there is no icon next to it
163176
.carbon-legend-item-line {
164177
height: 5px;
165178
padding-top: 1px;
166179
width: 28px;
167180
}
168181

182+
// refers to the line IF there is an icon next to it
169183
.carbon-legend-item-line-with-icon {
170184
height: 5px;
171185
padding-top: 1px;

0 commit comments

Comments
 (0)