This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01b648e
commit ccc078e
Showing
10 changed files
with
310 additions
and
95 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/components/IndividualServiceApiCallsChart/IndividualServiceApiCallsChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import LineChart from 'components/LineChart' | ||
import React, { useState } from 'react' | ||
import { useIndividualServiceApiCalls } from 'store/cache/analytics/hooks' | ||
import { Bucket, MetricError } from 'store/cache/analytics/slice' | ||
|
||
type OwnProps = { | ||
node: string | ||
} | ||
|
||
type IndividualServiceApiCallsChartProps = OwnProps | ||
|
||
const IndividualServiceApiCallsChart: React.FC<IndividualServiceApiCallsChartProps> = ({ | ||
node | ||
}) => { | ||
const [bucket, setBucket] = useState(Bucket.MONTH) | ||
|
||
const { apiCalls } = useIndividualServiceApiCalls(node, bucket) | ||
let error, labels, data | ||
if (apiCalls === MetricError.ERROR) { | ||
error = true | ||
labels = [] | ||
data = [] | ||
} else { | ||
labels = | ||
apiCalls?.map( | ||
a => new Date(parseInt(a.timestamp, 10) * 1000).getTime() / 1000 | ||
) ?? null | ||
data = apiCalls?.map(a => a.count) ?? null | ||
} | ||
return ( | ||
<LineChart | ||
title="API Calls" | ||
tooltipTitle="API Calls" | ||
error={error} | ||
data={data} | ||
labels={labels} | ||
selection={bucket} | ||
options={[Bucket.ALL_TIME, Bucket.MONTH, Bucket.WEEK]} | ||
onSelectOption={(option: string) => setBucket(option as Bucket)} | ||
showLeadingDay | ||
/> | ||
) | ||
} | ||
|
||
export default IndividualServiceApiCallsChart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './IndividualServiceApiCallsChart' |
45 changes: 45 additions & 0 deletions
45
src/components/IndividualServiceUniqueUsersChart/IndividualServiceUniqueUsersChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import LineChart from 'components/LineChart' | ||
import React, { useState } from 'react' | ||
import { useIndividualServiceApiCalls } from 'store/cache/analytics/hooks' | ||
import { Bucket, MetricError } from 'store/cache/analytics/slice' | ||
|
||
type OwnProps = { | ||
node: string | ||
} | ||
|
||
type IndividualServiceUniqueUsersChartProps = OwnProps | ||
|
||
const IndividualServiceUniqueUsersChart: React.FC<IndividualServiceUniqueUsersChartProps> = ({ | ||
node | ||
}) => { | ||
const [bucket, setBucket] = useState(Bucket.MONTH) | ||
|
||
const { apiCalls } = useIndividualServiceApiCalls(node, bucket) | ||
let error, labels, data | ||
if (apiCalls === MetricError.ERROR) { | ||
error = true | ||
labels = [] | ||
data = [] | ||
} else { | ||
labels = | ||
apiCalls?.map( | ||
a => new Date(parseInt(a.timestamp, 10) * 1000).getTime() / 1000 | ||
) ?? null | ||
data = apiCalls?.map(a => a.unique_count) ?? null | ||
} | ||
return ( | ||
<LineChart | ||
title="Unique Users" | ||
tooltipTitle="Unique Users" | ||
error={error} | ||
data={data} | ||
labels={labels} | ||
selection={bucket} | ||
options={[Bucket.ALL_TIME, Bucket.MONTH, Bucket.WEEK]} | ||
onSelectOption={(option: string) => setBucket(option as Bucket)} | ||
showLeadingDay | ||
/> | ||
) | ||
} | ||
|
||
export default IndividualServiceUniqueUsersChart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './IndividualServiceUniqueUsersChart' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
.container { | ||
display: inline-flex; | ||
width: 100%; | ||
} | ||
|
||
.section { | ||
margin-bottom: 16px; | ||
display: flex; | ||
margin-left: -8px; | ||
margin-right: -8px; | ||
} | ||
|
||
.section > * { | ||
width: 100%; | ||
margin: 0 8px; | ||
} | ||
|
||
.chart { | ||
min-height: 340px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.