-
Notifications
You must be signed in to change notification settings - Fork 16
/
chartjs.ur
39 lines (33 loc) · 1.21 KB
/
chartjs.ur
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
style chartjs_chart
type dataset = {
Label : string,
Values : list float
}
datatype graph =
Bar of list string * list dataset
| StackedBar of list string * list dataset
| Line of list string * list dataset
| Pie of list string * list dataset
| Doughnut of list string * list dataset
| PolarArea of list string * list dataset
| Radar of list string * list dataset
| Scatter of list {Label : string, Values : list {X : float, Y : float}}
| Bubble of list {Label : string, Values : list {X : float, Y : float, R : float}}
fun graphToFFI (g : graph) : ChartjsFfi.graph = case g of
Bar x => ChartjsFfi.Bar x
| StackedBar x => ChartjsFfi.StackedBar x
| Line x => ChartjsFfi.Line x
| Pie x => ChartjsFfi.Pie x
| Doughnut x => ChartjsFfi.Doughnut x
| PolarArea x => ChartjsFfi.PolarArea x
| Radar x => ChartjsFfi.Radar x
| Scatter x => ChartjsFfi.Scatter x
| Bubble x => ChartjsFfi.Bubble x
fun graph gr = <xml>
<active code={id <- fresh;
return <xml>
<div class="chartjs-chart" id={id}></div>
<active code={_ <- ChartjsFfi.setGraph id (graphToFFI gr);
return <xml/>}/>
</xml>}/>
</xml>