@@ -27,46 +27,131 @@ femto install Feliz.ChartJS
2727dotnet run
2828```
2929
30- ## Example ChartJS
31- Here is an example Line Chart:
30+ ## Supported Chart Types
31+
32+ | Chart Type | Component | Description |
33+ | ------------| -----------| -------------|
34+ | Line | ` ChartJS.line ` | Line charts for trends over time |
35+ | Bar | ` ChartJS.bar ` | Bar charts for categorical comparisons |
36+ | Pie | ` ChartJS.pie ` | Pie charts for proportional data |
37+ | Doughnut | ` ChartJS.doughnut ` | Doughnut charts (pie with hole) |
38+ | Radar | ` ChartJS.radar ` | Radar/spider charts for multivariate data |
39+ | PolarArea | ` ChartJS.polarArea ` | Polar area charts |
40+ | Scatter | ` ChartJS.scatter ` | Scatter plots for x/y data points |
41+ | Bubble | ` ChartJS.bubble ` | Bubble charts with x, y, and radius |
42+
43+ ## Example Line Chart
3244``` fs
3345ChartJS.line [
3446 line.options [
3547 option.responsive true
3648 option.plugins [
37- plugin.dataLabels [
38- dataLabels.display true
39- dataLabels.align Position.Bottom
40- dataLabels.borderRadius 3
41- dataLabels.color "red"
42- dataLabels.backgroundColor "green"
49+ plugin.legend [
50+ legend.position Position.Top
4351 ]
4452 ]
4553 ]
4654 line.data [
47- lineData.labels [| "Red "; "Blue "; "Yellow "; "Green "; "Purple "; "Orange " |]
55+ lineData.labels [| "Jan "; "Feb "; "Mar "; "Apr "; "May "; "Jun " |]
4856 lineData.datasets [|
4957 lineData.dataset [
50- lineDataSet.label "My First Dataset "
58+ lineDataSet.label "Sales 2024 "
5159 lineDataSet.borderColor "rgb(53, 162, 235)"
5260 lineDataSet.backgroundColor "rgba(53, 162, 235, 0.5)"
53- lineDataSet.data [| "1"; "2"; "3"; "4"; "5"; "6" |]
61+ lineDataSet.tension 0.4
62+ lineDataSet.fill true
63+ lineDataSet.data [| 10; 20; 15; 25; 22; 30 |]
5464 ]
55- lineData.dataset [
56- lineDataSet.label "My Second Dataset"
57- lineDataSet.borderColor "yellow"
58- lineDataSet.backgroundColor "rgba(53, 162, 235, 0.5)"
59- lineDataSet.data [| "1"; "2"; "3"; "4"; "4"; "6" |]
65+ |]
66+ ]
67+ ]
68+ ```
69+
70+ ## Example Radar Chart
71+ ``` fs
72+ ChartJS.radar [
73+ radar.options [
74+ option.responsive true
75+ ]
76+ radar.data [
77+ radarData.labels [| "Speed"; "Strength"; "Defense"; "Magic"; "Luck" |]
78+ radarData.datasets [|
79+ radarData.dataset [
80+ radarDataSet.label "Player Stats"
81+ radarDataSet.borderColor "rgb(255, 99, 132)"
82+ radarDataSet.backgroundColor "rgba(255, 99, 132, 0.2)"
83+ radarDataSet.pointBackgroundColor "rgb(255, 99, 132)"
84+ radarDataSet.data [| 80; 90; 70; 85; 65 |]
6085 ]
6186 |]
6287 ]
6388]
6489```
6590
66- ## Supported Chart Types
67- - Line Chart (` ChartJS.line ` )
68- - Bar Chart (` ChartJS.bar ` )
69- - Doughnut Chart (` ChartJS.doughnut ` )
70- - Bubble Chart (` ChartJS.bubble ` )
91+ ## Example Pie Chart
92+ ``` fs
93+ ChartJS.pie [
94+ pie.options [
95+ option.responsive true
96+ ]
97+ pie.data [
98+ pieData.labels [| "Red"; "Blue"; "Yellow" |]
99+ pieData.datasets [|
100+ pieData.dataset [
101+ pieDataSet.label "Votes"
102+ pieDataSet.backgroundColor [| "#FF6384"; "#36A2EB"; "#FFCE56" |]
103+ pieDataSet.data [| 12; 19; 3 |]
104+ ]
105+ |]
106+ ]
107+ ]
108+ ```
109+
110+ ## Features
111+
112+ ### Animation
113+ ``` fs
114+ option.animation [
115+ animation.duration 1000
116+ animation.easing Easing.EaseOutQuart
117+ animation.onComplete (fun _ -> printfn "Animation complete!")
118+ ]
119+ ```
120+
121+ ### Interaction
122+ ``` fs
123+ option.interaction [
124+ interaction.mode InteractionMode.Nearest
125+ interaction.intersect false
126+ interaction.axis InteractionAxis.X
127+ ]
128+ ```
129+
130+ ### Legend Events
131+ ``` fs
132+ plugin.legend [
133+ legend.position Position.Top
134+ legend.onClick (fun e item chart -> printfn "Clicked: %A" item)
135+ legend.onHover (fun e item -> printfn "Hovering: %A" item)
136+ ]
137+ ```
138+
139+ ### Chart Methods
140+ ``` fs
141+ open Feliz.ChartJS
142+
143+ // Get chart reference
144+ let chartRef = React.useRef<Interop.ChartJS option>(None)
145+
146+ // Use chart methods
147+ match chartRef.current with
148+ | Some chart ->
149+ ChartMethods.update chart (Some "none") // Update without animation
150+ ChartMethods.reset chart // Reset to initial state
151+ let imageData = ChartMethods.toBase64ImagePng chart // Export as PNG
152+ | None -> ()
153+ ```
154+
155+ ## Documentation
71156
72- You can find more examples [ here ] ( https://tforkmann.github.io/Feliz.ChartJS/ )
157+ You can find more examples and documentation at [ https://tforkmann.github.io/Feliz.ChartJS/ ] ( https://tforkmann.github.io/Feliz.ChartJS/ )
0 commit comments