Skip to content

Commit 091a833

Browse files
[FEATURE] Add chart tooltips (opensearch-project#225)
* [FEATURE] Add chart tooltips opensearch-project#198 Signed-off-by: Jovan Cvetkovic <[email protected]> * [FEATURE] Add chart tooltips opensearch-project#198 Signed-off-by: Jovan Cvetkovic <[email protected]> * [FEATURE] Add interactive legend into charts opensearch-project#199 Signed-off-by: Jovan Cvetkovic <[email protected]> * Reverting, pushed to wrong branch Signed-off-by: Jovan Cvetkovic <[email protected]> Signed-off-by: Jovan Cvetkovic <[email protected]>
1 parent 11e47b3 commit 091a833

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

cypress/integration/4_findings.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('Findings', () => {
136136
cy.contains('sample_detector').click({ force: true }, { timeout: 2000 });
137137

138138
// Click "Actions" button, the click "Delete"
139-
cy.get('button').contains('Actions').click({ force: true });
139+
cy.get('button').contains('Actions').click({ force: true }, { timeout: 2000 });
140140
cy.contains('Delete').click({ force: true });
141141

142142
// Search for sample_detector, presumably deleted

cypress/integration/5_integrations.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ describe('Integration tests', () => {
1919
const indexName = 'cypress-index-windows';
2020
const dnsName = 'cypress-index-dns';
2121

22-
before(() => {
23-
// Create custom rules
22+
const cleanUpTests = () => {
2423
cy.deleteAllCustomRules();
2524
cy.deleteAllDetectors();
2625
cy.deleteAllIndices();
26+
};
27+
28+
before(() => {
29+
cleanUpTests();
2730

2831
// Create custom rules
2932
cy.createRule(windows_usb_rule_data).then((response) => {
@@ -80,6 +83,8 @@ describe('Integration tests', () => {
8083
);
8184
});
8285

86+
after(() => cleanUpTests());
87+
8388
it('...can navigate to findings page', () => {
8489
cy.intercept({
8590
method: 'GET',

public/pages/Overview/utils/helpers.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,21 @@ export function getOverviewVisualizationSpec(
5858
title: 'Count',
5959
axis: { grid: true, ticks: false },
6060
},
61+
tooltip: [{ field: 'finding', aggregate: 'sum', type: 'quantitative', title: 'Findings' }],
6162
};
6263

63-
if (groupBy === 'log_type') {
64-
findingsEncoding['color'] = { field: 'logType', type: 'nominal', title: 'Log type' };
64+
if (groupBy === 'logType') {
65+
findingsEncoding['color'] = {
66+
field: 'logType',
67+
type: 'nominal',
68+
title: 'Log type',
69+
scale: {
70+
range: euiPaletteColorBlind(),
71+
},
72+
};
6573
}
6674

75+
const lineColor = '#ff0000';
6776
return getVisualizationSpec(
6877
'Plot showing average data with raw values in the background.',
6978
visualizationData,
@@ -75,11 +84,16 @@ export function getOverviewVisualizationSpec(
7584
{
7685
mark: {
7786
type: 'line',
78-
color: '#ff0000',
87+
color: lineColor,
88+
point: {
89+
filled: true,
90+
fill: lineColor,
91+
},
7992
},
8093
encoding: {
8194
x: { timeUnit, field: 'time', title: '', axis: { grid: false, ticks: false } },
8295
y: { aggregate, field: 'alert', title: 'Count', axis: { grid: true, ticks: false } },
96+
tooltip: [{ field: 'alert', aggregate: 'sum', title: 'Alerts' }],
8397
},
8498
},
8599
]
@@ -135,6 +149,7 @@ export function getFindingsVisualizationSpec(
135149
{
136150
mark: 'bar',
137151
encoding: {
152+
tooltip: [{ field: 'finding', aggregate: 'sum', type: 'quantitative', title: 'Findings' }],
138153
x: {
139154
timeUnit: dateOpts.timeUnit,
140155
field: 'time',
@@ -176,6 +191,7 @@ export function getAlertsVisualizationSpec(
176191
{
177192
mark: 'bar',
178193
encoding: {
194+
tooltip: [{ field: 'alert', aggregate: 'sum', title: 'Alerts' }],
179195
x: {
180196
timeUnit: dateOpts.timeUnit,
181197
field: 'time',
@@ -210,7 +226,30 @@ export function getTopRulesVisualizationSpec(visualizationData: any[]) {
210226
return getVisualizationSpec('Most frequent detection rules', visualizationData, [
211227
{
212228
mark: { type: 'arc', innerRadius: 90 },
229+
transform: [
230+
{
231+
joinaggregate: [
232+
{
233+
op: 'sum',
234+
field: 'count',
235+
as: 'total',
236+
},
237+
],
238+
},
239+
{
240+
calculate: 'datum.count/datum.total',
241+
as: 'percentage',
242+
},
243+
],
213244
encoding: {
245+
tooltip: [
246+
{
247+
field: 'percentage',
248+
title: 'Percentage',
249+
type: 'quantitative',
250+
format: '2.0%',
251+
},
252+
],
214253
theta: { aggregate: 'sum', field: 'count', type: 'quantitative' },
215254
color: {
216255
field: 'ruleName',

0 commit comments

Comments
 (0)