Skip to content

Commit 19763db

Browse files
muehlhauskMutagene
andauthored
Add statically typed color representation (#171)
Co-authored-by: Kevin Schneider <schneider.kev@outlook.de>
1 parent a1211d1 commit 19763db

41 files changed

Lines changed: 1087 additions & 471 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/1_3_shapes.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ multiple shapes at once.
4747

4848
open Plotly.NET.LayoutObjects
4949

50-
let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3")
51-
let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3")
50+
let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor= Color.fromHex "#d3d3d3")
51+
let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor= Color.fromHex "#d3d3d3")
5252

5353
let shapes =
5454
Chart.Line(x,y',Name="line")

docs/1_4_annotations.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ multiple annotations at once.
4949
open Plotly.NET.LayoutObjects
5050

5151
let a1 = Annotation.init (X=2.,Y=4.,Text = "Hi there!")
52-
let a2 = Annotation.init (X=5.,Y=7.,Text="I am another annotation!",BGColor="white",BorderColor="black")
52+
let a2 = Annotation.init (X=5.,Y=7.,Text="I am another annotation!",BGColor= Color.fromString "white",BorderColor= Color.fromString "black")
5353

5454
let annotations =
5555
Chart.Line(x,y',Name="line")

docs/2_3_range-plots.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ let range1 =
5252
Chart.Range(
5353
x,y,yUpper,yLower,
5454
StyleParam.Mode.Lines_Markers,
55-
Color="grey",
56-
RangeColor="lightblue")
55+
Color = Color.fromString "grey",
56+
RangeColor = Color.fromString "lightblue")
5757

5858
(*** condition: ipynb ***)
5959
#if IPYNB

docs/2_6_table.fsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ let table2 =
7979
//sets cell row colors
8080
//ColorCells=[["#deebf7";"lightgrey"]],
8181
//sets font of header
82-
FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color="white"),
82+
FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color=Color.fromString "white"),
8383
//sets the height of the header
8484
HeightHeader= 30.,
8585
//sets lines of header
86-
LineHeader = Line.init(2.,"black"),
86+
LineHeader = Line.init(2.,Color.fromString "black"),
8787
ColumnWidth = [70;50;100;70],
8888
//defines order of columns
8989
ColumnOrder = [1;2;3;4]
@@ -120,8 +120,8 @@ let mapColor min max value =
120120
let proportion =
121121
(255. * (value - min) / (max - min))
122122
|> int
123-
Colors.fromRgb 255 (255 - proportion) proportion
124-
|> Colors.toWebColor
123+
ARGB.fromRGB 255 (255 - proportion) proportion
124+
|> ARGB.toWebHex
125125

126126
//Assign a color to every cell seperately. Matrix must be transposed for correct orientation.
127127
let cellcolor =
@@ -196,7 +196,7 @@ let cellcolors =
196196
|> Seq.map (fun x -> Seq.append x (seq ["white"]))
197197

198198
let font = Font.init(FontFamily.Consolas,Size=14.)
199-
let line = Line.init(0.,"white")
199+
let line = Line.init(0.,Color.fromString "white")
200200
let chartwidth = 50. + 10. * float elementsPerRow
201201

202202
let table4 =

docs/4_5_splom.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Until that is fixed, consider creating splom plot programatically using `Chart.G
5252
*)
5353

5454
let splom1 =
55-
Chart.Splom(data,Color="blue")
55+
Chart.Splom(data,Color=Color.fromString "blue")
5656

5757
(*** condition: ipynb ***)
5858
#if IPYNB

docs/5_0_geo-vs-mapbox.fsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ let myGeo =
7272
Geo.init(
7373
Resolution=StyleParam.GeoResolution.R50,
7474
ShowCoastLines=true,
75-
CoastLineColor="RebeccaPurple",
75+
CoastLineColor=Color.fromString "RebeccaPurple",
7676
ShowLand=true,
77-
LandColor="LightGreen",
77+
LandColor=Color.fromString "LightGreen",
7878
ShowOcean=true,
79-
OceanColor="LightBlue",
79+
OceanColor=Color.fromString "LightBlue",
8080
ShowLakes=true,
81-
LakeColor="Blue",
81+
LakeColor=Color.fromString "Blue",
8282
ShowRivers=true,
83-
RiverColor="Blue"
83+
RiverColor=Color.fromString "Blue"
8484
)
8585

8686
let moreFeaturesBaseMap =
@@ -114,7 +114,7 @@ let countryGeo =
114114
Visible=false,
115115
Resolution=StyleParam.GeoResolution.R50,
116116
ShowCountries=true,
117-
CountryColor="RebeccaPurple"
117+
CountryColor=Color.fromString "RebeccaPurple"
118118
)
119119

120120

docs/5_1_geo-plots.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let pointGeo =
6464
|> Chart.withGeoStyle(
6565
Scope=StyleParam.GeoScope.NorthAmerica,
6666
Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea),
67-
CountryColor = "lightgrey"
67+
CountryColor = Color.fromString "lightgrey"
6868
)
6969
|> Chart.withMarginSize(0,0,0,0)
7070

@@ -106,7 +106,7 @@ let flights =
106106
Chart.LineGeo(
107107
[startCoords; endCoords],
108108
Opacity = opacityVals.[i],
109-
Color = "red"
109+
Color = Color.fromString "red"
110110
)
111111
)
112112
|> Chart.combine
@@ -115,7 +115,7 @@ let flights =
115115
Scope=StyleParam.GeoScope.NorthAmerica,
116116
Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea),
117117
ShowLand=true,
118-
LandColor = "lightgrey"
118+
LandColor = Color.fromString "lightgrey"
119119
)
120120
|> Chart.withMarginSize(0,0,50,0)
121121
|> Chart.withTitle "Feb. 2011 American Airline flights"

docs/5_2_choropleth-map.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ let choroplethMap2 =
124124
Projection=GeoProjection.init(projectionType=StyleParam.GeoProjectionType.Mollweide),
125125
ShowLakes=true,
126126
ShowOcean=true,
127-
OceanColor="lightblue",
127+
OceanColor=Color.fromString "lightblue",
128128
ShowRivers=true)
129129
|> Chart.withColorBarStyle (Title.init("Alcohol consumption[l/y]"),Length=0.5)
130130

@@ -244,7 +244,7 @@ let choroplethGeoJSON =
244244
Scope=StyleParam.GeoScope.NorthAmerica,
245245
Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea),
246246
ShowLand=true,
247-
LandColor = "lightgrey"
247+
LandColor = Color.fromString "lightgrey"
248248
)
249249
)
250250
|> Chart.withSize (800.,800.)

docs/6_1_mapbox-plots.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ let flights =
103103
Chart.LineMapbox(
104104
[startCoords; endCoords],
105105
Opacity = opacityVals.[i],
106-
Color = "red"
106+
Color = Color.fromString "red"
107107
)
108108
)
109109
|> Chart.combine

docs/7_1_funnel.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ open Plotly.NET
4545
open Plotly.NET.TraceObjects
4646

4747
// Customize the connector lines used to connect the funnel bars
48-
let connectorLine = Line.init (Color="royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.)
48+
let connectorLine = Line.init (Color=Color.fromString "royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.)
4949
let connector = FunnelConnector.init(Line=connectorLine)
5050

5151
// Customize the outline of the funnel bars
52-
let line = Line.init(Width=2.,Color="3E4E88")
52+
let line = Line.init(Width=2.,Color=Color.fromHex "3E4E88")
5353

5454
// create a funnel chart using custom connectors and outlines
5555
let funnel =
56-
Chart.Funnel (x,y,Color="59D4E8", Line=line, Connector=connector)
56+
Chart.Funnel (x,y,Color=Color.fromHex "59D4E8", Line=line, Connector=connector)
5757
|> Chart.withMarginSize(Left=100)
5858

5959
(*** condition: ipynb ***)

0 commit comments

Comments
 (0)