Skip to content

Commit 25559c1

Browse files
Recharts: Add AreaChart
1 parent 3ec8497 commit 25559c1

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/Fable.Recharts/Fable.Recharts.fs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ open Fable.Core
55
open Fable.Core.JsInterop
66

77
module Props =
8-
[<StringEnum>]
9-
type Layout =
8+
9+
type [<StringEnum>] Layout =
1010
| Horizontal
1111
| Vertical
1212

13-
[<StringEnum>]
14-
type StackOffset =
13+
type [<StringEnum>] StackOffset =
1514
| Expand
1615
| Wiggle
1716
| Silhouette
1817
| Sign
1918
| [<CompiledName("none")>] NoStackOffset
2019

21-
[<StringEnum>]
22-
type Interpolation =
20+
type [<StringEnum>] BaseValue =
21+
| DataMin
22+
| DataMax
23+
| Auto
24+
25+
type [<StringEnum>] Interpolation =
2326
| Basis
2427
| BasisClosed
2528
| BasisOpen
@@ -34,8 +37,7 @@ module Props =
3437
| StepAfter
3538
//| Function
3639

37-
[<StringEnum>]
38-
type Legend =
40+
type [<StringEnum>] Legend =
3941
| Line
4042
| Square
4143
| Rect
@@ -47,8 +49,7 @@ module Props =
4749
| Wye
4850
| [<CompiledName("none")>] NoLegend
4951

50-
[<StringEnum>]
51-
type Easing =
52+
type [<StringEnum>] Easing =
5253
| Ease
5354
| [<CompiledName("ease-in")>] EaseIn
5455
| [<CompiledName("ease-out")>] EaseOut
@@ -66,7 +67,7 @@ module Props =
6667
right: float
6768
left: float }
6869

69-
type ChartProp =
70+
type [<RequireQualifiedAccess>] ChartProp =
7071
/// If any two categorical charts(LineChart, AreaChart, BarChart, ComposedChart) have the same syncId, these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.
7172
| SyncId of string
7273
| Layout of Layout
@@ -86,14 +87,17 @@ module Props =
8687
/// BarChart: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape.
8788
| StackOffset of StackOffset
8889

90+
/// AreaChart: The base value of are.
91+
| BaseValue of U2<float, BaseValue>
92+
8993
// Events
9094
| OnClick of (React.MouseEvent -> unit)
9195
| OnMouseEnter of (React.MouseEvent -> unit)
9296
| OnMouseMove of (React.MouseEvent -> unit)
9397
| OnMouseLeave of (React.MouseEvent -> unit)
94-
static member Custom(key: string, value: obj): ChartProp = !!(key, value)
98+
static member inline Custom(key: string, value: obj): ChartProp = !!(key, value)
9599

96-
type CartesianProp =
100+
type [<RequireQualifiedAccess>] CartesianProp =
97101
/// The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
98102
| Type of Interpolation
99103
/// The key of a group of data which should be unique in a LineChart.
@@ -148,7 +152,8 @@ module Props =
148152
| OnMouseMove of (React.MouseEvent -> unit)
149153
| OnMouseLeave of (React.MouseEvent -> unit)
150154
interface Fable.Helpers.React.Props.IProp
151-
static member Custom(key: string, value: obj): ChartProp = !!(key, value)
155+
static member inline Custom(key: string, value: obj): ChartProp = !!(key, value)
156+
152157

153158
type RechartComponent =
154159
interface end
@@ -157,6 +162,7 @@ module Imports =
157162
// Charts
158163
let lineChartEl: obj = import "LineChart" "recharts"
159164
let barChartEl: obj = import "BarChart" "recharts"
165+
let areaChartEl: obj = import "AreaChart" "recharts"
160166

161167
// General Components
162168
let tooltipEl: obj = import "Tooltip" "recharts"
@@ -180,6 +186,10 @@ let inline lineChart (props: ChartProp list) (children: RechartComponent list):
180186
let inline barChart (props: ChartProp list) (children: RechartComponent list): React.ReactElement =
181187
createElement(barChartEl, keyValueList CaseRules.LowerFirst props, children)
182188

189+
let inline areaChart (props: ChartProp list) (children: RechartComponent list): React.ReactElement =
190+
createElement(areaChartEl, keyValueList CaseRules.LowerFirst props, children)
191+
192+
183193
// TODO: Tooltip props
184194
let inline tooltip (props: obj list): RechartComponent =
185195
createElement(tooltipEl, keyValueList CaseRules.LowerFirst props, [])

0 commit comments

Comments
 (0)