Skip to content

Commit

Permalink
[FEATURE] Add chart tooltips (opensearch-project#225)
Browse files Browse the repository at this point in the history
* [FEATURE] Add chart tooltips opensearch-project#198

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>

* [FEATURE] Add chart tooltips opensearch-project#198

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>

* [FEATURE] Add interactive legend into charts opensearch-project#199

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>

* Reverting, pushed to wrong branch

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>
  • Loading branch information
jovancvetkovic3006 authored Dec 16, 2022
1 parent 11e47b3 commit 091a833
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/4_findings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('Findings', () => {
cy.contains('sample_detector').click({ force: true }, { timeout: 2000 });

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

// Search for sample_detector, presumably deleted
Expand Down
9 changes: 7 additions & 2 deletions cypress/integration/5_integrations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ describe('Integration tests', () => {
const indexName = 'cypress-index-windows';
const dnsName = 'cypress-index-dns';

before(() => {
// Create custom rules
const cleanUpTests = () => {
cy.deleteAllCustomRules();
cy.deleteAllDetectors();
cy.deleteAllIndices();
};

before(() => {
cleanUpTests();

// Create custom rules
cy.createRule(windows_usb_rule_data).then((response) => {
Expand Down Expand Up @@ -80,6 +83,8 @@ describe('Integration tests', () => {
);
});

after(() => cleanUpTests());

it('...can navigate to findings page', () => {
cy.intercept({
method: 'GET',
Expand Down
45 changes: 42 additions & 3 deletions public/pages/Overview/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,21 @@ export function getOverviewVisualizationSpec(
title: 'Count',
axis: { grid: true, ticks: false },
},
tooltip: [{ field: 'finding', aggregate: 'sum', type: 'quantitative', title: 'Findings' }],
};

if (groupBy === 'log_type') {
findingsEncoding['color'] = { field: 'logType', type: 'nominal', title: 'Log type' };
if (groupBy === 'logType') {
findingsEncoding['color'] = {
field: 'logType',
type: 'nominal',
title: 'Log type',
scale: {
range: euiPaletteColorBlind(),
},
};
}

const lineColor = '#ff0000';
return getVisualizationSpec(
'Plot showing average data with raw values in the background.',
visualizationData,
Expand All @@ -75,11 +84,16 @@ export function getOverviewVisualizationSpec(
{
mark: {
type: 'line',
color: '#ff0000',
color: lineColor,
point: {
filled: true,
fill: lineColor,
},
},
encoding: {
x: { timeUnit, field: 'time', title: '', axis: { grid: false, ticks: false } },
y: { aggregate, field: 'alert', title: 'Count', axis: { grid: true, ticks: false } },
tooltip: [{ field: 'alert', aggregate: 'sum', title: 'Alerts' }],
},
},
]
Expand Down Expand Up @@ -135,6 +149,7 @@ export function getFindingsVisualizationSpec(
{
mark: 'bar',
encoding: {
tooltip: [{ field: 'finding', aggregate: 'sum', type: 'quantitative', title: 'Findings' }],
x: {
timeUnit: dateOpts.timeUnit,
field: 'time',
Expand Down Expand Up @@ -176,6 +191,7 @@ export function getAlertsVisualizationSpec(
{
mark: 'bar',
encoding: {
tooltip: [{ field: 'alert', aggregate: 'sum', title: 'Alerts' }],
x: {
timeUnit: dateOpts.timeUnit,
field: 'time',
Expand Down Expand Up @@ -210,7 +226,30 @@ export function getTopRulesVisualizationSpec(visualizationData: any[]) {
return getVisualizationSpec('Most frequent detection rules', visualizationData, [
{
mark: { type: 'arc', innerRadius: 90 },
transform: [
{
joinaggregate: [
{
op: 'sum',
field: 'count',
as: 'total',
},
],
},
{
calculate: 'datum.count/datum.total',
as: 'percentage',
},
],
encoding: {
tooltip: [
{
field: 'percentage',
title: 'Percentage',
type: 'quantitative',
format: '2.0%',
},
],
theta: { aggregate: 'sum', field: 'count', type: 'quantitative' },
color: {
field: 'ruleName',
Expand Down

0 comments on commit 091a833

Please sign in to comment.