Skip to content

Commit 5275842

Browse files
committed
Add Interface design
1 parent b4b6229 commit 5275842

21 files changed

+1974
-1587
lines changed

FSharp.Plotly.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
3434
docs\content\box-plots.fsx = docs\content\box-plots.fsx
3535
docs\content\bubble-charts.fsx = docs\content\bubble-charts.fsx
3636
docs\content\contour-plots.fsx = docs\content\contour-plots.fsx
37+
docs\content\getting-started.fsx = docs\content\getting-started.fsx
3738
docs\content\heatmaps.fsx = docs\content\heatmaps.fsx
3839
docs\content\histograms.fsx = docs\content\histograms.fsx
3940
docs\content\index.fsx = docs\content\index.fsx
4041
docs\content\line-scatter-plots.fsx = docs\content\line-scatter-plots.fsx
4142
docs\content\pie-daughnut-charts.fsx = docs\content\pie-daughnut-charts.fsx
43+
docs\content\plotly-wpf.fsx = docs\content\plotly-wpf.fsx
4244
docs\content\polar-charts.fsx = docs\content\polar-charts.fsx
4345
docs\content\range-plots.fsx = docs\content\range-plots.fsx
4446
EndProjectSection

docs/content/area-plots.fsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ let labels = ["Residential"; "Non-Residential"; "Utility"]
2020
(*** define-output:pie1 ***)
2121
Chart.Pie(values,labels)
2222
(*** include-it:pie1 ***)
23+
24+

docs/content/bar-charts.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let xValues = ["Product A"; "Product B"; "Product C";]
1919
let labels = ["27% market share"; "24% market share"; "19% market share";]
2020

2121
(*** define-output:pie1 ***)
22-
Chart.Bar(xValues,yValues,Labels=labels,Opacity=0.3,Marker=Options.Marker(color="rgba(222,45,38,0.8)"))
22+
Chart.Bar(xValues,yValues,Labels=labels,Opacity=0.3,Marker=Options.Marker(Color="rgba(222,45,38,0.8)"))
2323
|> Chart.withSize(500.,500.)
2424
(*** include-it:pie1 ***)
2525
|> Chart.Show

docs/content/getting-started.fsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(*** hide ***)
2+
// This block of code is omitted in the generated HTML documentation. Use
3+
// it to define helpers that you do not want to show in the documentation.
4+
#r "../../bin/Newtonsoft.Json.dll"
5+
6+
(**
7+
FSharp.Plotly
8+
======================
9+
10+
The library FSharp.Plotly implements charting suitable for use from F# scripting. Once you load the library as followed, you can use the members of the `Chart` type to easily build charts.
11+
12+
FSharp.Plotly is powered by popular JavaScript charting library [Plotly](https://plot.ly/). The library provides a complete mapping for the configuration options of the underlying library but empowers you to use the comfortable style known from the beautiful library [F# Charting](http://fslab.org/FSharp.Charting/). So you get a nice F# interface support with the full power of Plotly.
13+
*)
14+
15+
#r "../../bin/FSharp.Plotly.dll"
16+
open FSharp.Plotly
17+
18+
19+
20+
let trace =
21+
Scatter(
22+
x = [1; 2; 3; 4],
23+
y = [12; 9; 15; 12],
24+
mode = "lines+markers"
25+
//name = "lines and markers"
26+
)
27+
28+
let layout =
29+
Layout()
30+
31+
GenericChart.ofTraceObject trace layout
32+
|> Chart.Show
33+
34+
35+
36+

docs/content/heatmaps.fsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ let colorscaleValue =
2929
StyleOption.ColorScale.Custom [(0.0,"#3D9970");(1.0,"#001f3f")]
3030
// Generating the Heatmap
3131
(*** define-output:heat1 ***)
32-
Chart.HeatMap(matrix,colnames,rownames,Colorscale=colorscaleValue,Showscale=true)
32+
Chart.Heatmap(matrix,colnames,rownames,Colorscale=colorscaleValue,Showscale=true)
3333
|> Chart.withSize(700.,500.)
34-
|> Chart.withMarginSize(left=200.)
34+
|> Chart.withMarginSize(Left=200.)
3535
(*** include-it:heat1 ***)
36+
|> Chart.Show
37+

docs/content/line-scatter-plots.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let y' = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
2121

2222
(*** define-output:line1 ***)
2323
Chart.Line(x,y',Name="line")
24-
|> Chart.withLineStyle(Width=2,Dash=StyleOption.DrawingStyle.Dot);
24+
|> Chart.withLineStyle(Width=2,Dash=StyleOption.DrawingStyle.Dot)
2525
(*** include-it:line1 ***)
2626

2727
(**

docs/content/plotly-wpf.fsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(*** hide ***)
2+
// This block of code is omitted in the generated HTML documentation. Use
3+
// it to define helpers that you do not want to show in the documentation.
4+
#r "../../bin/Newtonsoft.Json.dll"
5+
6+
(**
7+
FSharp.Plotly
8+
======================
9+
10+
The library FSharp.Plotly implements charting suitable for use from F# scripting. Once you load the library as followed, you can use the members of the `Chart` type to easily build charts.
11+
12+
FSharp.Plotly is powered by popular JavaScript charting library [Plotly](https://plot.ly/). The library provides a complete mapping for the configuration options of the underlying library but empowers you to use the comfortable style known from the beautiful library [F# Charting](http://fslab.org/FSharp.Charting/). So you get a nice F# interface support with the full power of Plotly.
13+
*)
14+
15+
#r "../../bin/FSharp.Plotly.dll"
16+
#r "../../bin/FSharp.Plotly.WPF.dll"
17+
open FSharp.Plotly
18+
open FSharp.Plotly.WPF
19+
20+
(**
21+
Example
22+
-------
23+
24+
The following example creates a combined point and line chart:
25+
*)
26+
let x = [1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ]
27+
let y = [5.; 2.5; 5.; 7.5; 5.; 2.5; 7.5; 4.5; 5.5; 5.]
28+
let y' = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
29+
(**
30+
Create the combined chart
31+
*)
32+
(*** define-output:pie1 ***)
33+
[
34+
Chart.Point(x,y,Name="scattern");
35+
Chart.Line(x,y',Name="line")
36+
|> Chart.withLineStyle(Width=2);
37+
]
38+
|> Chart.Combine
39+
(*** include-it:pie1 ***)
40+
(**
41+
By piping the combined chart into `Chart.Show` function it will be displayed in your browser.
42+
*)
43+
(*** do-not-eval ***)
44+
|> Chart.Show

docs/tools/templates/template.cshtml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,31 @@
3939
<img src="@Root/img/logo.png" alt="FSharp.Plotly" style="width:150px;margin:10px" />
4040
<ul class="nav nav-list" id="menu" style="margin-top: 20px;">
4141
<li class="nav-header">@Properties["project-name"]</li>
42-
<li><a href="@Root/index.html">Home page</a></li>
42+
<li><a href="@Root/index.html">Home page</a></li>
4343
<li class="divider"></li>
44-
44+
<li><a href="@Root/getting-started.html">Getting started</a></li>
4545
<li class="nav-header">Plotly Charts</li>
46-
<li><a href="@Root/line-scatter-plots.html">Line and Scatter Plots</a></li>
47-
<li><a href="@Root/range-plots.html">Line and Scatter Plots</a></li>
48-
<li><a href="@Root/pie-daughnut-charts.html">Pie and Doughnut Charts</a></li>
49-
<li><a href="@Root/bar-charts.html">Bar</a></li>
50-
<li><a href="@Root/box-plots.html">Box Plots</a></li>
51-
<li><a href="@Root/area-plots.html">Area Plots</a></li>
52-
<li><a href="@Root/heatmaps.html">Heatmaps</a></li>
53-
<li><a href="@Root/bubble-charts.html">Bubble Charts</a></li>
54-
<li><a href="@Root/contour-plots.html">Contour Plots</a></li>
55-
<li><a href="@Root/histograms.html">Histograms</a></li>
56-
<li><a href="@Root/2d-histograms.html">2D Histograms</a></li>
57-
<li><a href="@Root/polar-charts.html">Polar Charts</a></li>
58-
46+
<li><a href="@Root/area-plots.html">Area Plots</a></li>
47+
<li><a href="@Root/bar-charts.html">Bar</a></li>
48+
<li><a href="@Root/box-plots.html">Box Plots</a></li>
49+
<li><a href="@Root/bubble-charts.html">Bubble Charts</a></li>
50+
<li><a href="@Root/contour-plots.html">Contour Plots</a></li>
51+
<li><a href="@Root/heatmaps.html">Heatmaps</a></li>
52+
<li><a href="@Root/histograms.html">Histograms</a></li>
53+
<li><a href="@Root/2d-histograms.html">2D Histograms</a></li>
54+
<li><a href="@Root/line-scatter-plots.html">Line and Scatter Plots</a></li>
55+
<li><a href="@Root/pie-daughnut-charts.html">Pie and Doughnut Charts</a></li>
56+
<li><a href="@Root/polar-charts.html">Polar Charts</a></li>
57+
<li><a href="@Root/range-plots.html">Range Plots</a></li>
5958
<li class="nav-header">Plotly 3d-Charts</li>
60-
<li><a href="@Root/3d-scatter-plots.html">3D Scatter Plots</a></li>
61-
<li><a href="@Root/3d-line-plots.html">3D Line Plots</a></li>
62-
<li><a href="@Root/3d-surface-plots.html">3D Surface Plots</a></li>
63-
64-
59+
<li><a href="@Root/3d-line-plots.html">3D Line Plots</a></li>
60+
<li><a href="@Root/3d-scatter-plots.html">3D Scatter Plots</a></li>
61+
<li><a href="@Root/3d-surface-plots.html">3D Surface Plots</a></li>
62+
<li class="nav-header">Plotly WPF</li>
63+
<li><a href="@Root/plotly-wpf.html">Using Plotly PopUp window</a></li>
6564

6665
<li class="nav-header">Documentation</li>
67-
<li><a href="@Root/reference/index.html">API Reference</a></li>
66+
<li><a href="@Root/reference/index.html">API Reference</a></li>
6867
</ul>
6968
</div>
7069
</div>

src/FSharp.Plotly/ApplyHelper.fs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
open System
44

55

6+
67
module ApplyHelper =
78

89
open System.Reflection
10+
11+
// Gets public properties including interface propterties
12+
let getPublicProperties (t:Type) =
13+
if (not (t.IsInterface)) then
14+
(t.GetProperties())
15+
else
16+
t.GetInterfaces()
17+
|> Array.collect (fun i -> i.GetProperties())
18+
19+
920

1021
/// Creates an instance of the Object according to applyStyle and applies the function..
1122
let buildApply (applyStyle:'a -> 'a) =
@@ -33,7 +44,11 @@ module ApplyHelper =
3344

3445
/// Sets property value using reflection
3546
let trySetPropertyValue (o:obj) (propName:string) (value:obj) =
36-
let property = o.GetType().GetProperty(propName)
47+
//let property = o.GetType().GetProperty(propName,BindingFlags.FlattenHierarchy)
48+
let property =
49+
getPublicProperties (o.GetType())
50+
|> Array.find (fun n -> n.Name = propName)
51+
printfn "%s" property.Name
3752
try
3853
property.SetValue(o, value, null)
3954
Some o
@@ -44,15 +59,15 @@ module ApplyHelper =
4459
/// Gets property value as option using reflection
4560
let tryGetPropertyValue (o:obj) (propName:string) =
4661
try
47-
Some (o.GetType().GetProperty(propName).GetValue(o, null))
62+
Some (o.GetType().GetProperty(propName,BindingFlags.FlattenHierarchy).GetValue(o, null))
4863
with
4964
| :? System.Reflection.TargetInvocationException -> None
5065
| :? System.NullReferenceException -> None
5166

5267
/// Gets property value as 'a option using reflection. Cast to 'a
5368
let tryGetPropertyValueAs<'a> (o:obj) (propName:string) =
5469
try
55-
let v = (o.GetType().GetProperty(propName).GetValue(o, null))
70+
let v = (o.GetType().GetProperty(propName,BindingFlags.FlattenHierarchy).GetValue(o, null))
5671
Some (v :?> 'a)
5772
with
5873
| :? System.Reflection.TargetInvocationException -> None

0 commit comments

Comments
 (0)