Skip to content

Commit 38f1f3b

Browse files
Recharts: Add ComposedChart, PieChart, RadarChart, RadialBarChart, ScatterChart
1 parent 25559c1 commit 38f1f3b

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

src/Fable.Recharts/Fable.Recharts.fs

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module Props =
6767
right: float
6868
left: float }
6969

70-
type [<RequireQualifiedAccess>] ChartProp =
70+
type [<RequireQualifiedAccess>] Chart =
7171
/// 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.
7272
| SyncId of string
7373
| Layout of Layout
@@ -90,14 +90,33 @@ module Props =
9090
/// AreaChart: The base value of are.
9191
| BaseValue of U2<float, BaseValue>
9292

93+
/// ComposedChart: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
94+
| ReverseStackOrder of bool
95+
96+
/// RadarChart: [Percentage (e.g. "50%") | Number] The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width.
97+
| Cx of obj
98+
/// RadarChart: [Percentage (e.g. "50%") | Number] The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height.
99+
| Cy of obj
100+
/// RadarChart: The angle of first radial direction line.
101+
| StartAngle of float
102+
/// RadarChart: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
103+
| EndAngle of float
104+
/// RadarChart: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
105+
| InnerRadius of obj
106+
/// RadarChart: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
107+
| OuterRadius of obj
108+
93109
// Events
94110
| OnClick of (React.MouseEvent -> unit)
95-
| OnMouseEnter of (React.MouseEvent -> unit)
111+
| OnMouseDown of (React.MouseEvent -> unit)
112+
| OnMouseUp of (React.MouseEvent -> unit)
96113
| OnMouseMove of (React.MouseEvent -> unit)
114+
| OnMouseOver of (React.MouseEvent -> unit)
115+
| OnMouseEnter of (React.MouseEvent -> unit)
97116
| OnMouseLeave of (React.MouseEvent -> unit)
98-
static member inline Custom(key: string, value: obj): ChartProp = !!(key, value)
117+
static member inline Custom(key: string, value: obj): Chart = !!(key, value)
99118

100-
type [<RequireQualifiedAccess>] CartesianProp =
119+
type [<RequireQualifiedAccess>] Cartesian =
101120
/// The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
102121
| Type of Interpolation
103122
/// The key of a group of data which should be unique in a LineChart.
@@ -152,7 +171,7 @@ module Props =
152171
| OnMouseMove of (React.MouseEvent -> unit)
153172
| OnMouseLeave of (React.MouseEvent -> unit)
154173
interface Fable.Helpers.React.Props.IProp
155-
static member inline Custom(key: string, value: obj): ChartProp = !!(key, value)
174+
static member inline Custom(key: string, value: obj): Chart = !!(key, value)
156175

157176

158177
type RechartComponent =
@@ -163,6 +182,11 @@ module Imports =
163182
let lineChartEl: obj = import "LineChart" "recharts"
164183
let barChartEl: obj = import "BarChart" "recharts"
165184
let areaChartEl: obj = import "AreaChart" "recharts"
185+
let composedChartEl: obj = import "ComposedChart" "recharts"
186+
let pieChartEl: obj = import "PieChart" "recharts"
187+
let radarChartEl: obj = import "RadarChart" "recharts"
188+
let radialBarChartEl: obj = import "RadialBarChart" "recharts"
189+
let scatterChartEl: obj = import "ScatterChart" "recharts"
166190

167191
// General Components
168192
let tooltipEl: obj = import "Tooltip" "recharts"
@@ -180,15 +204,29 @@ open Fable.Helpers.React.Props
180204
open Props
181205
open Imports
182206

183-
let inline lineChart (props: ChartProp list) (children: RechartComponent list): React.ReactElement =
207+
let inline lineChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
184208
createElement(lineChartEl, keyValueList CaseRules.LowerFirst props, children)
185209

186-
let inline barChart (props: ChartProp list) (children: RechartComponent list): React.ReactElement =
210+
let inline barChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
187211
createElement(barChartEl, keyValueList CaseRules.LowerFirst props, children)
188212

189-
let inline areaChart (props: ChartProp list) (children: RechartComponent list): React.ReactElement =
213+
let inline areaChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
190214
createElement(areaChartEl, keyValueList CaseRules.LowerFirst props, children)
191215

216+
let inline composedChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
217+
createElement(composedChartEl, keyValueList CaseRules.LowerFirst props, children)
218+
219+
let inline pieChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
220+
createElement(pieChartEl, keyValueList CaseRules.LowerFirst props, children)
221+
222+
let inline radarChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
223+
createElement(radarChartEl, keyValueList CaseRules.LowerFirst props, children)
224+
225+
let inline radialBarChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
226+
createElement(radialBarChartEl, keyValueList CaseRules.LowerFirst props, children)
227+
228+
let inline scatterChart (props: Chart list) (children: RechartComponent list): React.ReactElement =
229+
createElement(scatterChartEl, keyValueList CaseRules.LowerFirst props, children)
192230

193231
// TODO: Tooltip props
194232
let inline tooltip (props: obj list): RechartComponent =

0 commit comments

Comments
 (0)