Skip to content

Commit 22e03c7

Browse files
feat: option to add legend on left side (#1520)
1 parent 020afb4 commit 22e03c7

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

projects/observability/src/shared/components/legend/legend.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ export const enum LegendPosition {
6868
TopRight = 'top-right',
6969
TopLeft = 'top-left',
7070
Top = 'top',
71+
Left = 'left',
7172
None = 'none'
7273
}

projects/observability/src/shared/components/utils/d3/d3-visualization-builder.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export abstract class D3VisualizationBuilderService<
117117
return 'column-reverse';
118118
case LegendPosition.Right:
119119
return 'row';
120+
case LegendPosition.Left:
121+
return 'row-reverse';
120122
case LegendPosition.None:
121123
return '';
122124
default:
@@ -222,7 +224,7 @@ export abstract class D3VisualizationBuilderService<
222224

223225
const isLegendVisible = this.isLegendVisible(config);
224226
const isTopOrBottomLegend = this.isTopOrBottomLegend(config);
225-
const isSideLegend = config.legend === LegendPosition.Right;
227+
const isSideLegend = config.legend === LegendPosition.Right || config.legend === LegendPosition.Left;
226228
let legendWidth = isLegendVisible
227229
? 0
228230
: isSideLegend
@@ -312,6 +314,7 @@ export abstract class D3VisualizationBuilderService<
312314
protected getLegendLayout(configuration: TInternalConfig): LegendLayout {
313315
switch (configuration.legend) {
314316
case LegendPosition.Right:
317+
case LegendPosition.Left:
315318
return LegendLayout.Column;
316319
case LegendPosition.Top:
317320
case LegendPosition.TopRight:

projects/observability/src/shared/components/utils/d3/d3-visualization.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
}
1414
}
1515

16+
&.row-reverse {
17+
flex-direction: row-reverse;
18+
.chart-legend-container {
19+
margin-left: 12px;
20+
margin-right: 12px;
21+
}
22+
}
23+
1624
&.column {
1725
flex-direction: column;
1826
.chart-legend-container {

0 commit comments

Comments
 (0)