Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vega tooltips to use custom tooltip format #368

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f78f8dd
[FEATURE] Detector must have at least one alert set #288
jovancvetkovic3006 Jan 9, 2023
1ea796c
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 11, 2023
a7f7b7a
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 14, 2023
1180e2c
[FEATURE] Upgrade Vega-tooltips plugin version #254
jovancvetkovic3006 Jan 16, 2023
0d514d8
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 16, 2023
b8f3399
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 17, 2023
4c03561
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 19, 2023
40793f0
Upgrade vega tooltips to use custom tooltip format #368
jovancvetkovic3006 Jan 19, 2023
ff8117e
[BUG] Create detector | Interval field can be empty #378
jovancvetkovic3006 Jan 23, 2023
2316863
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 23, 2023
b308059
Adjust styling for Finding details flyout #369
jovancvetkovic3006 Jan 24, 2023
73fae1f
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 24, 2023
7a41744
unit tests
jovancvetkovic3006 Jan 24, 2023
06be7da
detector unit tests
jovancvetkovic3006 Jan 25, 2023
f0ccd00
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 25, 2023
6bf765e
detector unit tests
jovancvetkovic3006 Jan 26, 2023
36b6390
detector unit tests
jovancvetkovic3006 Jan 26, 2023
c23a669
detector unit tests
jovancvetkovic3006 Jan 26, 2023
ce0944b
detector unit tests
jovancvetkovic3006 Jan 26, 2023
d37fb41
detector unit tests
jovancvetkovic3006 Jan 26, 2023
d523098
detector unit tests
jovancvetkovic3006 Jan 26, 2023
8ef0bd0
detector unit tests
jovancvetkovic3006 Jan 26, 2023
9c71aa8
detector unit tests
jovancvetkovic3006 Jan 27, 2023
bc50e0a
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
a659826
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
31a5803
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
31c02b0
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
460e7d2
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 1, 2023
482b2c7
unit tests review
jovancvetkovic3006 Feb 1, 2023
b4ed7fa
unit tests review
jovancvetkovic3006 Feb 3, 2023
8381d32
unit tests review
jovancvetkovic3006 Feb 3, 2023
2933d63
unit tests review
jovancvetkovic3006 Feb 3, 2023
378ea69
unit tests review
jovancvetkovic3006 Feb 3, 2023
84b225a
unit tests review
jovancvetkovic3006 Feb 3, 2023
9fa4df8
unit tests review
jovancvetkovic3006 Feb 3, 2023
7e03bfd
unit tests review
jovancvetkovic3006 Feb 3, 2023
237325a
Feature/update vertical domain #372
jovancvetkovic3006 Feb 3, 2023
a967890
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 10, 2023
5422508
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
d54ce17
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
926e249
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
092efff
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
8a2246b
Unit tests for public components #383
jovancvetkovic3006 Feb 11, 2023
fa436c4
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 16, 2023
95c6db8
Unit tests for public components #383
jovancvetkovic3006 Feb 16, 2023
6dab0ee
PR code review
jovancvetkovic3006 Feb 16, 2023
239150f
PR code review
jovancvetkovic3006 Feb 16, 2023
9b212fb
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 19, 2023
9d747b3
PR code review
jovancvetkovic3006 Feb 19, 2023
5d7dab6
PR code review
jovancvetkovic3006 Feb 19, 2023
20d215c
PR code review
jovancvetkovic3006 Feb 19, 2023
94a8788
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 19, 2023
c86731e
PR code review
jovancvetkovic3006 Feb 20, 2023
efe585d
Merge branch 'unit_tests_for_public_components' of https://github.com…
jovancvetkovic3006 Feb 20, 2023
4a1a539
PR code review
jovancvetkovic3006 Feb 20, 2023
dcc5d27
[FEATURE] Create detector | Make data source multi-select field #419
jovancvetkovic3006 Feb 21, 2023
d124223
unit tests fix
jovancvetkovic3006 Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 68 additions & 2 deletions public/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ $euiColorGhost: #FFF !default;
$euiColorInk: #000 !default;
$euiTextColor: $euiColorDarkestShade !default;

@import "./components/Charts/ChartContainer.scss";
@import "./pages/Overview/components/Widgets/WidgetContainer.scss";

.selected-radio-panel {
background-color: tintOrShade($euiColorPrimary, 90%, 70%);
border-color: $euiColorPrimary;
Expand Down Expand Up @@ -45,5 +48,68 @@ $euiTextColor: $euiColorDarkestShade !default;
text-decoration: none;
}

@import "./components/Charts/ChartContainer.scss";
@import "./pages/Overview/components/Widgets/WidgetContainer.scss";
.vg-tooltip {
background-color: #404040 !important;
border-radius: 4px !important;
color: #FFFFFF !important;
border: none !important;
padding: 0 !important;
font-family: "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol" !important;
font-weight: 600 !important;
font-size: 12px !important;

.vg-tooltip-innerContainer {
.vg-tooltip-header {
border-bottom: 1px solid gray;
table tr:nth-child(odd) {
background-color: #535353 !important;
}

td:nth-child(1) {
position: relative;
width: 6px;
padding: 0 0 0 2px !important;

.vg-tooltip-color {
width: 4px;
position: absolute;
top: 2px;
height: calc(100% - 4px);
}
}
td:nth-child(3) {
padding-right: 8px !important;
text-align: right;
}
}

.vg-tooltip-body {
padding: 4px;

table tr:nth-child(even) {
background-color: #535353 !important;
}

td:nth-child(2) {
text-align: right;
}
}

table {
width: 100%;

tbody tr {
td {
height: 28px;
padding: 4px !important;
vertical-align: middle !important;
}

td:nth-child(1) {
padding-right: 10px !important;
font-weight: 400 !important;
}
}
}
}
}
56 changes: 54 additions & 2 deletions public/utils/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { RuleInfo } from '../../server/models/interfaces';
import { NotificationsStart } from 'opensearch-dashboards/public';
import { OpenSearchService } from '../services';
import { Handler } from 'vega-tooltip';
import _ from 'lodash';

export const parseStringsToOptions = (strings: string[]) => {
return strings.map((str) => ({ id: str, label: str }));
Expand Down Expand Up @@ -165,14 +166,65 @@ export function renderVisualization(spec: TopLevelSpec, containerId: string) {
}

function renderVegaSpec(spec: {}) {
const handler = new Handler();
let pathGroup: any[] = [];
jovancacvetkovic marked this conversation as resolved.
Show resolved Hide resolved
const handler = new Handler({
formatTooltip: (value, sanitize) => {
let tooltipData = { ...value };
let values = Object.entries(tooltipData);
if (!values.length) return '';
const tooltipItem = pathGroup.filter((groupItem: any) =>
_.isEqual(groupItem.tooltip, tooltipData)
);
const color = tooltipItem.length
? tooltipItem[0].fill || tooltipItem[0].stroke
: 'transparent';

const firstItem = values.pop() || ['', ''];

let rowData = '';
values.forEach((item: any) => {
rowData += `
<tr>
<td>${sanitize(item[0])}</td>
<td>${sanitize(item[1])}</td>
</tr>
`;
});
let tableData = `<table>${rowData}</table>`;
jovancacvetkovic marked this conversation as resolved.
Show resolved Hide resolved

return `
<div class="vg-tooltip-innerContainer">
<div class="vg-tooltip-header">
<table>
<tr>
<td><div class="vg-tooltip-color" style="background-color: ${color}"></div></td>
<td>${sanitize(firstItem[0])}</td>
<td>${sanitize(firstItem[1])}</td>
</tr>
</table>
</div>
<div class="vg-tooltip-body">
${tableData}
</div>
</div>
`;
},
});
view = new View(parse(spec, null, { expr: vegaExpressionInterpreter }), {
renderer: 'canvas', // renderer (canvas or svg)
container: `#${containerId}`, // parent DOM container
hover: true, // enable hover processing
});
view.tooltip(handler.call);
return view.runAsync();
return view.runAsync().then((view: any) => {
const items = view.scenegraph().root.items[0].items || [];
const groups = items.filter(
(item: any) => item.name && item.name.match(/^(layer_).*(_marks)$/)
);
for (let item of groups) {
pathGroup = pathGroup.concat(item.items);
}
});
}
}

Expand Down