-
Notifications
You must be signed in to change notification settings - Fork 26
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
b089409
commit 6490f38
Showing
3 changed files
with
140 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
external barGraphOptionsToJson: BarGraphTypes.barGraphOptions => JSON.t = "%identity" | ||
@react.component | ||
let make = (~entity, ~data: JSON.t, ~className="") => { | ||
open NewAnalyticsTypes | ||
let object = entity.getObjects(data) | ||
let options = entity.getChatOptions(object)->barGraphOptionsToJson | ||
|
||
<div className> | ||
<Highcharts.Chart options highcharts={Highcharts.highcharts} /> | ||
</div> | ||
} |
82 changes: 82 additions & 0 deletions
82
src/screens/NewAnalytics/Graphs/BarGraph/BarGraphTypes.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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
type \"type" = string | ||
type spacingLeft = int | ||
type spacingRight = int | ||
|
||
type categories = array<string> | ||
type crosshair = bool | ||
type barWidth = int | ||
type align = string | ||
type color = string | ||
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 bar = {marker: marker} | ||
type plotOptions = {bar: bar} | ||
type labels = { | ||
align: align, | ||
style: style, | ||
} | ||
type chart = { | ||
\"type": \"type", | ||
spacingLeft: spacingLeft, | ||
spacingRight: spacingRight, | ||
} | ||
|
||
type dataObj = { | ||
showInLegend: showInLegend, | ||
name: name, | ||
data: array<int>, | ||
color: color, | ||
} | ||
|
||
type data = array<dataObj> | ||
|
||
type yAxis = { | ||
title: title, | ||
gridLineWidth: gridLineWidth, | ||
gridLineColor: gridLineColor, | ||
gridLineDashStyle: gridLineDashStyle, | ||
tickmarkPlacement: tickmarkPlacement, | ||
endOnTick: endOnTick, | ||
startOnTick: startOnTick, | ||
min: min, | ||
} | ||
|
||
type xAxis = { | ||
categories: categories, | ||
crosshair: crosshair, | ||
barWidth: barWidth, | ||
labels: labels, | ||
gridLineDashStyle: gridLineDashStyle, | ||
} | ||
|
||
type barGraphOptions = { | ||
chart: chart, | ||
title: title, | ||
xAxis: xAxis, | ||
yAxis: yAxis, | ||
plotOptions: plotOptions, | ||
series: data, | ||
credits: credits, | ||
} | ||
|
||
type barGraphPayload = {categories: categories, data: data, title: title} |
47 changes: 47 additions & 0 deletions
47
src/screens/NewAnalytics/Graphs/BarGraph/BarGraphUtils.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
open BarGraphTypes | ||
let getBarGraphOptions = (barGraphOptions: barGraphPayload) => { | ||
let {categories, data, title} = barGraphOptions | ||
{ | ||
chart: { | ||
\"type": "bar", | ||
spacingLeft: 20, | ||
spacingRight: 20, | ||
}, | ||
title: { | ||
text: "", | ||
}, | ||
xAxis: { | ||
categories, | ||
crosshair: true, | ||
barWidth: 1, | ||
labels: { | ||
align: "center", | ||
style: { | ||
color: "#999", | ||
}, | ||
}, | ||
gridLineDashStyle: "Dash", | ||
}, | ||
yAxis: { | ||
title, | ||
gridLineWidth: 1, | ||
gridLineColor: "#e6e6e6", | ||
gridLineDashStyle: "Solid", | ||
tickmarkPlacement: "on", | ||
endOnTick: false, | ||
startOnTick: false, | ||
min: 0, | ||
}, | ||
plotOptions: { | ||
bar: { | ||
marker: { | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
series: data, | ||
credits: { | ||
enabled: false, | ||
}, | ||
} | ||
} |