Skip to content

Commit

Permalink
***TO REVERT THIS***
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmylonas committed Nov 20, 2020
1 parent ff86feb commit fa7884e
Showing 1 changed file with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,70 @@
*/

import React from 'react';
import { Flex } from 'pouncejs';
import { Box, Flex, SimpleGrid } from 'pouncejs';
import TimeSeriesChart from 'Components/charts/TimeSeriesChart';
import { LongSeriesData } from 'Generated/schema';
import { stringToPaleColor } from 'Helpers/colors';

interface EventsByLogTypesProps {
events: LongSeriesData;
}

const getTooltip = (aggregate: { [key: string]: number }) => {
return (
<SimpleGrid columns={2} spacing={3}>
{Object.keys(aggregate).map(logType => (
<Flex key={logType} justify="space-between" spacing={2}>
<Flex spacing={2} align="center">
<Box
as="span"
width={12}
height={12}
backgroundColor={stringToPaleColor(logType) as any}
// @ts-ignore The pounce property is not transformed for unknown reasons
borderRadius="10px"
/>
<Box as="span" fontSize="x-small" fontWeight="normal" lineHeight="typical">
{logType}
</Box>
</Flex>
<Box font="mono" fontWeight="bold">
{aggregate[logType].toLocaleString('en')}
{` Hits`}
</Box>
</Flex>
))}
</SimpleGrid>
);
};
const EventsByLogTypes: React.FC<EventsByLogTypesProps> = ({ events }) => {
const metadata = events.series[0].values
.map(value => ({
'AWS.ALB': value / 4,
'Okta.SystemLog': value / 4,
'AWS.S3': value / 8,
'AWS.1': value / 8,
'AWS.2': value / 8,
'GSuite:': value / 16,
'Slackaa.1': value / 16,
'Slackaaaaaa.2': value / 16,
}))
.map(obj => ({ tooltip: getTooltip(obj) }));
const data = {
series: [{ ...events.series[0], color: 'indigo-600' }],
timestamps: events.timestamps,
metadata,
};
return (
<Flex data-testid="events-by-log-type-chart" height="100%" position="relative">
<TimeSeriesChart data={events} zoomable />
<TimeSeriesChart
data={data}
zoomable
chartType="bar"
hideLegend
units="Hits"
hideSeriesLabels={false}
/>
</Flex>
);
};
Expand Down

0 comments on commit fa7884e

Please sign in to comment.