Skip to content

Commit 8423015

Browse files
authored
Bug Fix: Make axis edit button appear when prospective-fob-area is hovered (#6083)
#6081 but with only css ## Motivation for features / changes Enabling the prospective fob feature prevents the X Axis from being edited on the scalar card. ## Technical description of changes The prospective fob area lies directly on top of the X Axis and thus prevents it from being hovered. To resolve this I used CSS reach across the components and change the visibility of the extent edit button when the prospective fob area is hovered. ## Screenshots of UI changes ![image](https://user-images.githubusercontent.com/78179109/204612638-29cf9008-6409-41a3-96c6-94e88c4a179b.png) ## Detailed steps to verify changes work correctly (as executed by you) 1) Start tensorboard 2) Navigate to http://localhost:6006/?enableLinkedTime=true&enableDataTable=true&allowRangeSelection=true&enableProspectiveFob=true#timeseries 3) Hover the X Axis of a scalar card 4) Assert the axis edit button appears ## Alternate designs / implementations considered #6081 I considered reordering the DOM to place the fobs within the axis component but thought there would be issues with the lines. While this seems possible it doesn't seem worth the complexity. I also considered either making hovering the entire chart cause the edit button to appear or making only hovering the corner cause the edit button to appear. Unfortunately I consider both of those to be a reduction of functionality. I also considered removing the prospective fob area and piping DOM events from the XAxis to the card_fob_controller_component but I felt that lead to a lot of confusing code. https://github.com/tensorflow/tensorboard/compare/master...rileyajones:tensorboard:axis-edit-piping?expand=1
1 parent 8828a59 commit 8423015

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ limitations under the License.
5757
position: absolute;
5858
// Height/Width to match x-axis
5959
height: 30px;
60-
width: calc(100% - 50px); // dot on the left takes up 50px
60+
width: calc(
61+
100% - 74px
62+
); // the dot on the left takes up 50px, the edit button takes up 24px
6163
}
6264

6365
.prospective-area {

tensorboard/webapp/widgets/line_chart_v2/line_chart_component.ng.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-->
1717

1818
<div
19-
[ngClass]="{'container': true, 'dark-mode': useDarkMode, 'line-only-mode': lineOnly}"
19+
[ngClass]="{'container': true, 'dark-mode': useDarkMode, 'line-only-mode': lineOnly, 'line-chart': true}"
2020
detectResize
2121
(onResize)="onViewResize()"
2222
[resizeEventDebouncePeriodInMs]="0"

tensorboard/webapp/widgets/line_chart_v2/sub_view/line_chart_axis_view.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,15 @@ $_border-style: 1px solid mat.get-color-from-palette(mat.$gray-palette, 500);
215215
transform-origin: center;
216216
}
217217
}
218+
219+
// Why this weird hack?
220+
// The prospective fob area is absolutely positioned over the XAxis.
221+
// This prevents hover events from reaching the XAxis.
222+
// The .extent-edit-button should appear when the XAxis is hovered.
223+
.line-chart:has(.horizontal-prospective-area:hover) {
224+
.x-axis {
225+
.extent-edit-button {
226+
visibility: visible;
227+
}
228+
}
229+
}

tensorboard/webapp/widgets/line_chart_v2/sub_view/line_chart_axis_view.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
EventEmitter,
1919
Input,
2020
Output,
21+
ViewEncapsulation,
2122
} from '@angular/core';
2223
import {Dimension, Formatter, Scale} from '../lib/public_types';
2324
import {LinearScale, TemporalScale} from '../lib/scale';
@@ -34,6 +35,9 @@ const AXIS_FONT = '11px Roboto, sans-serif';
3435
templateUrl: 'line_chart_axis_view.ng.html',
3536
styleUrls: ['line_chart_axis_view.css'],
3637
changeDetection: ChangeDetectionStrategy.OnPush,
38+
// This prevents the CSS generated from being namespaced thus allowing CSS
39+
// to reach into the line_chart_component and card_fob_controller_component
40+
encapsulation: ViewEncapsulation.None,
3741
})
3842
export class LineChartAxisComponent {
3943
@Input()

0 commit comments

Comments
 (0)