-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jeeva Ramachandran <[email protected]> Co-authored-by: Jeeva Ramachandran <[email protected]>
- Loading branch information
1 parent
d652667
commit ba4e885
Showing
10 changed files
with
218 additions
and
118 deletions.
There are no files selected for viewing
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,16 +1,8 @@ | ||
external lineGraphOptionsToJson: LineGraphTypes.lineGraphOptions => JSON.t = "%identity" | ||
@react.component | ||
let make = (~entity) => { | ||
let make = (~entity, ~data: JSON.t) => { | ||
open NewAnalyticsTypes | ||
open NewAnalyticsHelper | ||
|
||
let options = JSON.Encode.string("")->entity.getObjects->entity.getChatOptions | ||
|
||
<div> | ||
<h2 className="font-semibold text-xl text-jp-gray-900 pb-5"> {entity.title->React.string} </h2> | ||
<Card> | ||
<div className="mr-3 my-10"> | ||
<Highcharts.Chart options highcharts={Highcharts.highcharts} /> | ||
</div> | ||
</Card> | ||
</div> | ||
let data = entity.getObjects(data) | ||
let options = entity.getChatOptions(data) | ||
<Highcharts.Chart options={options->lineGraphOptionsToJson} highcharts={Highcharts.highcharts} /> | ||
} |
86 changes: 82 additions & 4 deletions
86
src/screens/NewAnalytics/Graphs/LineGraph/LineGraphTypes.res
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,6 +1,84 @@ | ||
type seriresType = { | ||
showInLegend: bool, | ||
name: string, | ||
type \"type" = string | ||
type spacingLeft = int | ||
type spacingRight = int | ||
|
||
type categories = array<string> | ||
type crosshair = bool | ||
type lineWidth = int | ||
type tickWidth = int | ||
type align = string | ||
type color = string | ||
type y = int | ||
type gridLineWidth = int | ||
type gridLineColor = string | ||
type gridLineDashStyle = string | ||
type tickmarkPlacement = string | ||
type endOnTick = bool | ||
type startOnTick = bool | ||
type min = int | ||
type showInLegend = bool | ||
type name = string | ||
|
||
type title = {text: string} | ||
type style = {color: color} | ||
type enabled = {enabled: bool} | ||
type credits = { | ||
...enabled, | ||
} | ||
type exporting = { | ||
...enabled, | ||
} | ||
type marker = { | ||
...enabled, | ||
} | ||
type line = {marker: marker} | ||
type plotOptions = {line: line} | ||
type labels = { | ||
align: align, | ||
style: style, | ||
y: y, | ||
} | ||
type chart = { | ||
\"type": \"type", | ||
spacingLeft: spacingLeft, | ||
spacingRight: spacingRight, | ||
} | ||
type data = { | ||
showInLegend: showInLegend, | ||
name: name, | ||
data: array<int>, | ||
color: string, | ||
color: color, | ||
} | ||
|
||
type yAxis = { | ||
title: title, | ||
gridLineWidth: gridLineWidth, | ||
gridLineColor: gridLineColor, | ||
gridLineDashStyle: gridLineDashStyle, | ||
min: min, | ||
} | ||
|
||
type xAxis = { | ||
categories: categories, | ||
crosshair: crosshair, | ||
lineWidth: lineWidth, | ||
tickWidth: tickWidth, | ||
labels: labels, | ||
gridLineWidth: gridLineWidth, | ||
gridLineColor: gridLineColor, | ||
tickmarkPlacement: tickmarkPlacement, | ||
endOnTick: endOnTick, | ||
startOnTick: startOnTick, | ||
} | ||
|
||
type lineGraphOptions = { | ||
chart: chart, | ||
title: title, | ||
xAxis: xAxis, | ||
yAxis: yAxis, | ||
plotOptions: plotOptions, | ||
series: data, | ||
credits: credits, | ||
} | ||
|
||
type lineGraphPayload = {categories: categories, data: data, title: title} |
51 changes: 50 additions & 1 deletion
51
src/screens/NewAnalytics/Graphs/LineGraph/LineGraphUtils.res
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 +1,50 @@ | ||
|
||
open LineGraphTypes | ||
let getLineGraphOptions = (lineGraphOptions: lineGraphPayload) => { | ||
let {categories, data, title} = lineGraphOptions | ||
{ | ||
chart: { | ||
\"type": "line", | ||
spacingLeft: 20, | ||
spacingRight: 20, | ||
}, | ||
title: { | ||
text: "", | ||
}, | ||
xAxis: { | ||
categories, | ||
crosshair: true, | ||
lineWidth: 1, | ||
tickWidth: 1, | ||
labels: { | ||
align: "center", | ||
style: { | ||
color: "#666", | ||
}, | ||
y: 35, | ||
}, | ||
gridLineWidth: 1, | ||
gridLineColor: "#e6e6e6", | ||
tickmarkPlacement: "on", | ||
endOnTick: false, | ||
startOnTick: false, | ||
}, | ||
yAxis: { | ||
title, | ||
gridLineWidth: 1, | ||
gridLineColor: "#e6e6e6", | ||
gridLineDashStyle: "Dash", | ||
min: 0, | ||
}, | ||
plotOptions: { | ||
line: { | ||
marker: { | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
series: data, | ||
credits: { | ||
enabled: false, | ||
}, | ||
} | ||
} |
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,8 +1,12 @@ | ||
external sankeyGraphOptionsToJson: SankeyGraphTypes.sankeyGraphOptions => JSON.t = "%identity" | ||
|
||
@react.component | ||
let make = (~options) => { | ||
let make = (~entity, ~data: JSON.t) => { | ||
open NewAnalyticsTypes | ||
Highcharts.sankeyChartModule(Highcharts.highchartsModule) | ||
|
||
let data = entity.getObjects(data) | ||
let options = entity.getChatOptions(data) | ||
<Highcharts.Chart | ||
options={options->Identity.genericTypeToJson} highcharts={Highcharts.highcharts} | ||
options={options->sankeyGraphOptionsToJson} highcharts={Highcharts.highcharts} | ||
/> | ||
} |
30 changes: 29 additions & 1 deletion
30
src/screens/NewAnalytics/OverViewAnalytics/OverViewAnalytics.res
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,6 +1,34 @@ | ||
module PaymentsProcessed = { | ||
open NewAnalyticsTypes | ||
open NewAnalyticsHelper | ||
open LineGraphTypes | ||
@react.component | ||
let make = (~entity: entity<lineGraphPayload, lineGraphOptions>) => { | ||
let (paymentsProcessed, setpaymentsProcessed) = React.useState(_ => JSON.Encode.null) | ||
let getPaymentsProcessed = async () => { | ||
try { | ||
setpaymentsProcessed(_ => JSON.Encode.null) | ||
} catch { | ||
| _ => () | ||
} | ||
} | ||
React.useEffect(() => { | ||
getPaymentsProcessed()->ignore | ||
None | ||
}, []) | ||
<div> | ||
<h2 className="font-600 text-xl text-jp-gray-900 pb-5"> {entity.title->React.string} </h2> | ||
<Card> | ||
<div className="mr-3 my-10"> | ||
<LineGraph entity={entity} data={paymentsProcessed} /> | ||
</div> | ||
</Card> | ||
</div> | ||
} | ||
} | ||
@react.component | ||
let make = () => { | ||
<div className="flex flex-col gap-5 mt-5"> | ||
<LineGraph entity={NewPaymentAnalyticsEntity.paymentsProcessedEntity} /> | ||
<PaymentsProcessed entity={OverViewAnalyticsEntity.paymentsProcessed} /> | ||
</div> | ||
} |
12 changes: 11 additions & 1 deletion
12
src/screens/NewAnalytics/OverViewAnalytics/OverViewAnalyticsEntity.res
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 +1,11 @@ | ||
|
||
open NewAnalyticsTypes | ||
let paymentsProcessed: entity<LineGraphTypes.lineGraphPayload, LineGraphTypes.lineGraphOptions> = { | ||
requestBodyConfig: { | ||
delta: false, | ||
metrics: [#payment_processed_amount], | ||
}, | ||
title: "Payments Processed", | ||
domain: #payments, | ||
getObjects: OverViewAnalyticsUtils.paymentsProcessedMapper, | ||
getChatOptions: LineGraphUtils.getLineGraphOptions, | ||
} |
27 changes: 26 additions & 1 deletion
27
src/screens/NewAnalytics/OverViewAnalytics/OverViewAnalyticsUtils.res
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 +1,26 @@ | ||
|
||
let paymentsProcessedMapper = (_json): LineGraphTypes.lineGraphPayload => { | ||
open LineGraphTypes | ||
let categories = [ | ||
"01 Aug", | ||
"02 Aug", | ||
"03 Aug", | ||
"04 Aug", | ||
"05 Aug", | ||
"06 Aug", | ||
"07 Aug", | ||
"08 Aug", | ||
"09 Aug", | ||
"10 Aug", | ||
"11 Aug", | ||
] | ||
let data = { | ||
showInLegend: false, | ||
name: "Series 1", | ||
data: [3000, 5000, 7000, 5360, 4500, 6800, 5400, 3000, 0, 0], | ||
color: "#2f7ed8", | ||
} | ||
let title = { | ||
text: "USD", | ||
} | ||
{categories, data, title} | ||
} |
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
Oops, something went wrong.