Skip to content

Commit 4dba5f4

Browse files
rileyajonesdna2github
authored andcommitted
Bug Fix: Update line chart encapsulation (tensorflow#6092)
## Motivation for features / changes tensorflow#6083 changed the way scss is namespaced. This fixed one issue but created others For Googlers: Before cl/493268254 After cl/493373147 ## Technical description of changes I created a do nothing component that simply disables scss encapsulation to enable intercomponent styling. ## Screenshots of UI changes Before: ![image](https://user-images.githubusercontent.com/78179109/206013391-afbda6cb-b05d-467f-b60f-7165c50af74a.png) After: ![image](https://user-images.githubusercontent.com/78179109/206012972-d04d4b41-1d1b-49b6-95a4-4d8eeeab6018.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) Hover the Y Axis and assert the edit button appears in the top left corner (not the top right) 5) Assert the axis edit button appears 6) View an image card and assert the axis is NOT gray ## Alternate designs / implementations considered We could have manually encapsulated all the css classes
1 parent 927eb6c commit 4dba5f4

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#overlayTarget="cdkOverlayOrigin"
2424
cdkOverlayOrigin
2525
>
26+
<line-chart-unencapsulated></line-chart-unencapsulated>
2627
<div class="series-view" #seriesView>
2728
<line-chart-grid-view
2829
*ngIf="!lineOnly"

tensorboard/webapp/widgets/line_chart_v2/sub_view/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tf_ng_module(
2222
"line_chart_grid_view.ts",
2323
"line_chart_interactive_utils.ts",
2424
"line_chart_interactive_view.ts",
25+
"line_chart_unencapsulated.ts",
2526
"sub_view_module.ts",
2627
],
2728
assets = [

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

-12
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,3 @@ $_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

-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
EventEmitter,
1919
Input,
2020
Output,
21-
ViewEncapsulation,
2221
} from '@angular/core';
2322
import {Dimension, Formatter, Scale} from '../lib/public_types';
2423
import {LinearScale, TemporalScale} from '../lib/scale';
@@ -35,9 +34,6 @@ const AXIS_FONT = '11px Roboto, sans-serif';
3534
templateUrl: 'line_chart_axis_view.ng.html',
3635
styleUrls: ['line_chart_axis_view.css'],
3736
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,
4137
})
4238
export class LineChartAxisComponent {
4339
@Input()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
==============================================================================*/
15+
import {
16+
ChangeDetectionStrategy,
17+
Component,
18+
ViewEncapsulation,
19+
} from '@angular/core';
20+
21+
@Component({
22+
selector: 'line-chart-unencapsulated',
23+
template: '',
24+
styles: [
25+
/**
26+
* Why this weird hack?
27+
* The prospective fob area is absolutely positioned over the XAxis.
28+
* This prevents hover events from reaching the XAxis.
29+
* The .extent-edit-button should appear when the XAxis is hovered.
30+
*/
31+
`
32+
.line-chart:has(.horizontal-prospective-area:hover) {
33+
.x-axis {
34+
.extent-edit-button {
35+
visibility: visible;
36+
}
37+
}
38+
}
39+
`,
40+
],
41+
changeDetection: ChangeDetectionStrategy.OnPush,
42+
// This prevents the CSS generated from being namespaced thus allowing CSS
43+
// to reach into the line_chart_component and card_fob_controller_component
44+
encapsulation: ViewEncapsulation.None,
45+
})
46+
export class LineChartUnencapsulated {}

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

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {MatMenuModule} from '@angular/material/menu';
2222
import {LineChartAxisComponent} from './line_chart_axis_view';
2323
import {LineChartGridView} from './line_chart_grid_view';
2424
import {LineChartInteractiveViewComponent} from './line_chart_interactive_view';
25+
import {LineChartUnencapsulated} from './line_chart_unencapsulated';
2526

2627
/**
2728
* SubViewModule provides UI elements for a traditional line chart; axes, grid, and
@@ -33,11 +34,13 @@ import {LineChartInteractiveViewComponent} from './line_chart_interactive_view';
3334
LineChartAxisComponent,
3435
LineChartInteractiveViewComponent,
3536
LineChartGridView,
37+
LineChartUnencapsulated,
3638
],
3739
exports: [
3840
LineChartAxisComponent,
3941
LineChartInteractiveViewComponent,
4042
LineChartGridView,
43+
LineChartUnencapsulated,
4144
],
4245
imports: [
4346
CommonModule,

0 commit comments

Comments
 (0)