From 19763db129b9160906964d9831ff3f67279926cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=C3=BChlhaus?= Date: Sat, 4 Sep 2021 08:55:07 +0200 Subject: [PATCH] Add statically typed color representation (#171) Co-authored-by: Kevin Schneider --- docs/1_3_shapes.fsx | 4 +- docs/1_4_annotations.fsx | 2 +- docs/2_3_range-plots.fsx | 4 +- docs/2_6_table.fsx | 10 +- docs/4_5_splom.fsx | 2 +- docs/5_0_geo-vs-mapbox.fsx | 12 +- docs/5_1_geo-plots.fsx | 6 +- docs/5_2_choropleth-map.fsx | 4 +- docs/6_1_mapbox-plots.fsx | 2 +- docs/7_1_funnel.fsx | 6 +- docs/7_2_funnel_area.fsx | 2 +- docs/8_0_polar_line-scatter-plots.fsx | 2 +- docs/8_2_styling_polar_layouts.fsx | 4 +- docs/9_0_parallel-categories.fsx | 2 +- docs/9_1_parallel-coords.fsx | 4 +- src/Plotly.NET/ChartAPI/Chart2D.fs | 4 +- src/Plotly.NET/ChartAPI/ChartDomain.fs | 48 +- .../CommonAbstractions/ColorKeyword.fs | 595 ++++++++++++++++++ src/Plotly.NET/CommonAbstractions/Colors.fs | 332 +++++----- src/Plotly.NET/CommonAbstractions/Font.fs | 8 +- src/Plotly.NET/CommonAbstractions/Line.fs | 20 +- .../ObjectAbstractions/Common/Annotation.fs | 46 +- .../Layout/ObjectAbstractions/Common/Shape.fs | 26 +- .../Layout/ObjectAbstractions/Map/Geo.fs | 80 +-- .../ObjectAbstractions/Polar/AngularAxis.fs | 92 +-- .../ObjectAbstractions/Polar/RadialAxis.fs | 98 +-- src/Plotly.NET/Plotly.NET.fsproj | 1 + src/Plotly.NET/Template/Template.fs | 4 +- .../Traces/ObjectAbstractions/Marker.fs | 52 +- src/Plotly.NET/Traces/Trace.fs | 10 +- src/Plotly.NET/Traces/Trace2D.fs | 2 +- src/Plotly.NET/Traces/TraceDomain.fs | 2 +- .../Plotly.NET.Tests.FSharpConsole/Program.fs | 2 +- .../HtmlCodegen/CategoricalCharts.fs | 16 +- .../HtmlCodegen/ChartLayout.fs | 6 +- .../HtmlCodegen/DistributionCharts.fs | 2 +- .../HtmlCodegen/FinanceCharts.fs | 8 +- .../HtmlCodegen/GeoMapCharts.fs | 20 +- .../HtmlCodegen/MapboxMapCharts.fs | 2 +- .../HtmlCodegen/PolarCharts.fs | 2 +- .../HtmlCodegen/SimpleCharts.fs | 14 +- 41 files changed, 1087 insertions(+), 471 deletions(-) create mode 100644 src/Plotly.NET/CommonAbstractions/ColorKeyword.fs diff --git a/docs/1_3_shapes.fsx b/docs/1_3_shapes.fsx index 735038745..0466acf1f 100644 --- a/docs/1_3_shapes.fsx +++ b/docs/1_3_shapes.fsx @@ -47,8 +47,8 @@ multiple shapes at once. open Plotly.NET.LayoutObjects -let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3") -let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3") +let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor= Color.fromHex "#d3d3d3") +let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor= Color.fromHex "#d3d3d3") let shapes = Chart.Line(x,y',Name="line") diff --git a/docs/1_4_annotations.fsx b/docs/1_4_annotations.fsx index e1b580b3c..8dec3571a 100644 --- a/docs/1_4_annotations.fsx +++ b/docs/1_4_annotations.fsx @@ -49,7 +49,7 @@ multiple annotations at once. open Plotly.NET.LayoutObjects let a1 = Annotation.init (X=2.,Y=4.,Text = "Hi there!") -let a2 = Annotation.init (X=5.,Y=7.,Text="I am another annotation!",BGColor="white",BorderColor="black") +let a2 = Annotation.init (X=5.,Y=7.,Text="I am another annotation!",BGColor= Color.fromString "white",BorderColor= Color.fromString "black") let annotations = Chart.Line(x,y',Name="line") diff --git a/docs/2_3_range-plots.fsx b/docs/2_3_range-plots.fsx index 9e20861e8..43cbcb163 100644 --- a/docs/2_3_range-plots.fsx +++ b/docs/2_3_range-plots.fsx @@ -52,8 +52,8 @@ let range1 = Chart.Range( x,y,yUpper,yLower, StyleParam.Mode.Lines_Markers, - Color="grey", - RangeColor="lightblue") + Color = Color.fromString "grey", + RangeColor = Color.fromString "lightblue") (*** condition: ipynb ***) #if IPYNB diff --git a/docs/2_6_table.fsx b/docs/2_6_table.fsx index fb1bbf1cf..539ea0eb6 100644 --- a/docs/2_6_table.fsx +++ b/docs/2_6_table.fsx @@ -79,11 +79,11 @@ let table2 = //sets cell row colors //ColorCells=[["#deebf7";"lightgrey"]], //sets font of header - FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color="white"), + FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color=Color.fromString "white"), //sets the height of the header HeightHeader= 30., //sets lines of header - LineHeader = Line.init(2.,"black"), + LineHeader = Line.init(2.,Color.fromString "black"), ColumnWidth = [70;50;100;70], //defines order of columns ColumnOrder = [1;2;3;4] @@ -120,8 +120,8 @@ let mapColor min max value = let proportion = (255. * (value - min) / (max - min)) |> int - Colors.fromRgb 255 (255 - proportion) proportion - |> Colors.toWebColor + ARGB.fromRGB 255 (255 - proportion) proportion + |> ARGB.toWebHex //Assign a color to every cell seperately. Matrix must be transposed for correct orientation. let cellcolor = @@ -196,7 +196,7 @@ let cellcolors = |> Seq.map (fun x -> Seq.append x (seq ["white"])) let font = Font.init(FontFamily.Consolas,Size=14.) -let line = Line.init(0.,"white") +let line = Line.init(0.,Color.fromString "white") let chartwidth = 50. + 10. * float elementsPerRow let table4 = diff --git a/docs/4_5_splom.fsx b/docs/4_5_splom.fsx index 422383c79..7574dfd91 100644 --- a/docs/4_5_splom.fsx +++ b/docs/4_5_splom.fsx @@ -52,7 +52,7 @@ Until that is fixed, consider creating splom plot programatically using `Chart.G *) let splom1 = - Chart.Splom(data,Color="blue") + Chart.Splom(data,Color=Color.fromString "blue") (*** condition: ipynb ***) #if IPYNB diff --git a/docs/5_0_geo-vs-mapbox.fsx b/docs/5_0_geo-vs-mapbox.fsx index 371110514..5a23a089f 100644 --- a/docs/5_0_geo-vs-mapbox.fsx +++ b/docs/5_0_geo-vs-mapbox.fsx @@ -72,15 +72,15 @@ let myGeo = Geo.init( Resolution=StyleParam.GeoResolution.R50, ShowCoastLines=true, - CoastLineColor="RebeccaPurple", + CoastLineColor=Color.fromString "RebeccaPurple", ShowLand=true, - LandColor="LightGreen", + LandColor=Color.fromString "LightGreen", ShowOcean=true, - OceanColor="LightBlue", + OceanColor=Color.fromString "LightBlue", ShowLakes=true, - LakeColor="Blue", + LakeColor=Color.fromString "Blue", ShowRivers=true, - RiverColor="Blue" + RiverColor=Color.fromString "Blue" ) let moreFeaturesBaseMap = @@ -114,7 +114,7 @@ let countryGeo = Visible=false, Resolution=StyleParam.GeoResolution.R50, ShowCountries=true, - CountryColor="RebeccaPurple" + CountryColor=Color.fromString "RebeccaPurple" ) diff --git a/docs/5_1_geo-plots.fsx b/docs/5_1_geo-plots.fsx index cbf6e5a10..82695d348 100644 --- a/docs/5_1_geo-plots.fsx +++ b/docs/5_1_geo-plots.fsx @@ -64,7 +64,7 @@ let pointGeo = |> Chart.withGeoStyle( Scope=StyleParam.GeoScope.NorthAmerica, Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea), - CountryColor = "lightgrey" + CountryColor = Color.fromString "lightgrey" ) |> Chart.withMarginSize(0,0,0,0) @@ -106,7 +106,7 @@ let flights = Chart.LineGeo( [startCoords; endCoords], Opacity = opacityVals.[i], - Color = "red" + Color = Color.fromString "red" ) ) |> Chart.combine @@ -115,7 +115,7 @@ let flights = Scope=StyleParam.GeoScope.NorthAmerica, Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea), ShowLand=true, - LandColor = "lightgrey" + LandColor = Color.fromString "lightgrey" ) |> Chart.withMarginSize(0,0,50,0) |> Chart.withTitle "Feb. 2011 American Airline flights" diff --git a/docs/5_2_choropleth-map.fsx b/docs/5_2_choropleth-map.fsx index e260e9d62..daff72ff7 100644 --- a/docs/5_2_choropleth-map.fsx +++ b/docs/5_2_choropleth-map.fsx @@ -124,7 +124,7 @@ let choroplethMap2 = Projection=GeoProjection.init(projectionType=StyleParam.GeoProjectionType.Mollweide), ShowLakes=true, ShowOcean=true, - OceanColor="lightblue", + OceanColor=Color.fromString "lightblue", ShowRivers=true) |> Chart.withColorBarStyle (Title.init("Alcohol consumption[l/y]"),Length=0.5) @@ -244,7 +244,7 @@ let choroplethGeoJSON = Scope=StyleParam.GeoScope.NorthAmerica, Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea), ShowLand=true, - LandColor = "lightgrey" + LandColor = Color.fromString "lightgrey" ) ) |> Chart.withSize (800.,800.) diff --git a/docs/6_1_mapbox-plots.fsx b/docs/6_1_mapbox-plots.fsx index 2eea6656f..ff428cdce 100644 --- a/docs/6_1_mapbox-plots.fsx +++ b/docs/6_1_mapbox-plots.fsx @@ -103,7 +103,7 @@ let flights = Chart.LineMapbox( [startCoords; endCoords], Opacity = opacityVals.[i], - Color = "red" + Color = Color.fromString "red" ) ) |> Chart.combine diff --git a/docs/7_1_funnel.fsx b/docs/7_1_funnel.fsx index 09f3cf997..e33b8fc9c 100644 --- a/docs/7_1_funnel.fsx +++ b/docs/7_1_funnel.fsx @@ -45,15 +45,15 @@ open Plotly.NET open Plotly.NET.TraceObjects // Customize the connector lines used to connect the funnel bars -let connectorLine = Line.init (Color="royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.) +let connectorLine = Line.init (Color=Color.fromString "royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.) let connector = FunnelConnector.init(Line=connectorLine) // Customize the outline of the funnel bars -let line = Line.init(Width=2.,Color="3E4E88") +let line = Line.init(Width=2.,Color=Color.fromHex "3E4E88") // create a funnel chart using custom connectors and outlines let funnel = - Chart.Funnel (x,y,Color="59D4E8", Line=line, Connector=connector) + Chart.Funnel (x,y,Color=Color.fromHex "59D4E8", Line=line, Connector=connector) |> Chart.withMarginSize(Left=100) (*** condition: ipynb ***) diff --git a/docs/7_2_funnel_area.fsx b/docs/7_2_funnel_area.fsx index bbeeb09e3..b3ed8fb7d 100644 --- a/docs/7_2_funnel_area.fsx +++ b/docs/7_2_funnel_area.fsx @@ -44,7 +44,7 @@ to visualizing funnel data. open Plotly.NET -let line = Line.init (Color="purple", Width=3.) +let line = Line.init (Color=Color.fromString "purple", Width=3.) let funnelArea = Chart.FunnelArea(Values=values, Text=text, Line=line) diff --git a/docs/8_0_polar_line-scatter-plots.fsx b/docs/8_0_polar_line-scatter-plots.fsx index 712daca20..3fab7881e 100644 --- a/docs/8_0_polar_line-scatter-plots.fsx +++ b/docs/8_0_polar_line-scatter-plots.fsx @@ -75,7 +75,7 @@ You can for example change the line style using `Chart.withLineStyle` let linePolar = Chart.LinePolar(radial,theta) - |> Chart.withLineStyle(Color="purple",Dash=StyleParam.DrawingStyle.DashDot) + |> Chart.withLineStyle(Color=Color.fromString "purple",Dash=StyleParam.DrawingStyle.DashDot) (*** condition: ipynb ***) #if IPYNB diff --git a/docs/8_2_styling_polar_layouts.fsx b/docs/8_2_styling_polar_layouts.fsx index 2f455f588..80738ca9c 100644 --- a/docs/8_2_styling_polar_layouts.fsx +++ b/docs/8_2_styling_polar_layouts.fsx @@ -97,13 +97,13 @@ let styledPolar2 = styledPolar |> Chart.withAngularAxis( AngularAxis.init( - Color="darkblue" + Color=Color.fromString "darkblue" ) ) |> Chart.withRadialAxis( RadialAxis.init( Title = Title.init("Hi, i am the radial axis"), - Color="darkblue", + Color=Color.fromString "darkblue", SeparateThousands = true ) ) diff --git a/docs/9_0_parallel-categories.fsx b/docs/9_0_parallel-categories.fsx index e30decad0..01293b91b 100644 --- a/docs/9_0_parallel-categories.fsx +++ b/docs/9_0_parallel-categories.fsx @@ -45,7 +45,7 @@ let dims = let parcats = Chart.ParallelCategories( dims, - Color=[0.;1.;0.;1.;0.;0.;0.], + Color = Color.fromColorScaleValues [0.;1.;0.;1.;0.;0.;0.], Colorscale = StyleParam.Colorscale.Blackbody ) diff --git a/docs/9_1_parallel-coords.fsx b/docs/9_1_parallel-coords.fsx index d5b70d83c..fa256aa91 100644 --- a/docs/9_1_parallel-coords.fsx +++ b/docs/9_1_parallel-coords.fsx @@ -53,7 +53,7 @@ the position of the vertex on the i-th axis corresponds to the i-th coordinate o *) let parcoords1 = - Chart.ParallelCoord(data,Color="blue") + Chart.ParallelCoord(data,Color=Color.fromString "blue") (*** condition: ipynb ***) #if IPYNB @@ -83,7 +83,7 @@ let parcoords = let dyn = Trace("parcoords") dyn?dimensions <- v - dyn?line <- Line.init(Color = "blue") + dyn?line <- Line.init(Color=Color.fromString "blue") dyn |> GenericChart.ofTraceObject diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 38d95a338..01325643a 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -602,7 +602,7 @@ module Chart2D = Trace2DStyle.Scatter(X = x,Y = lower, Mode=StyleParam.Mode.Lines, ?FillColor=RangeColor) ) |> TraceStyle.TraceInfo(?Name = Some lowerName, Showlegend=false) |> TraceStyle.Line(Width=0.) - |> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else "rgba(0,0,0,0.5)") + |> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else (Plotly.NET.Color.fromString "rgba(0,0,0,0.5)")) |> TraceStyle.TextLabel(?Text=LowerLabels,?Textposition=TextPosition,?Textfont=TextFont) let upper = @@ -610,7 +610,7 @@ module Chart2D = Trace2DStyle.Scatter(X = x,Y = upper, Mode=StyleParam.Mode.Lines, ?FillColor=RangeColor, Fill=StyleParam.Fill.ToNext_y) ) |> TraceStyle.TraceInfo(?Name = Some upperName, Showlegend=false) |> TraceStyle.Line(Width=0.) - |> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else "rgba(0,0,0,0.5)") + |> TraceStyle.Marker(Color=if RangeColor.IsSome then RangeColor.Value else (Plotly.NET.Color.fromString "rgba(0,0,0,0.5)")) |> TraceStyle.TextLabel(?Text=UpperLabels,?Textposition=TextPosition,?Textfont=TextFont) GenericChart.MultiChart ([lower;upper;trace],Layout(),Config(), DisplayOptions()) diff --git a/src/Plotly.NET/ChartAPI/ChartDomain.fs b/src/Plotly.NET/ChartAPI/ChartDomain.fs index 65c48bb1c..8609ab9df 100644 --- a/src/Plotly.NET/ChartAPI/ChartDomain.fs +++ b/src/Plotly.NET/ChartAPI/ChartDomain.fs @@ -21,7 +21,7 @@ module ChartDomain = [] ?Labels:seq<'IConvertible>, [] ?Name, [] ?Showlegend, - [] ?Colors, + [] ?Color, [] ?TextPosition, [] ?TextFont, [] ?Hoverinfo, @@ -29,7 +29,7 @@ module ChartDomain = [] ?Opacity) = TraceDomain.initPie (TraceDomainStyle.Pie(Values=values,?Labels=Labels,?Textinfo=Textinfo)) |> TraceStyle.TraceInfo(?Name=Name,?Showlegend=Showlegend,?Opacity=Opacity,?Hoverinfo=Hoverinfo) - |> TraceStyle.Marker(?Colors=Colors) + |> TraceStyle.Marker(?Color=Color) |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) |> GenericChart.ofTraceObject @@ -38,14 +38,14 @@ module ChartDomain = static member Pie(data:seq<#IConvertible*#IConvertible>, [] ?Name, [] ?Showlegend, - [] ?Colors, + [] ?Color, [] ?TextPosition, [] ?TextFont, [] ?Hoverinfo, [] ?Textinfo, [] ?Opacity) = let values,labels = Seq.unzip data - Chart.Pie(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Colors=Colors,?TextPosition=TextPosition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity) + Chart.Pie(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Color=Color,?TextPosition=TextPosition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity) /// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data as a whole. @@ -53,7 +53,7 @@ module ChartDomain = [] ?Labels, [] ?Name, [] ?Showlegend, - [] ?Colors, + [] ?Color, [] ?Hole, [] ?TextPosition, [] ?TextFont, @@ -63,7 +63,7 @@ module ChartDomain = let hole' = if Hole.IsSome then Hole.Value else 0.4 TraceDomain.initPie (TraceDomainStyle.Pie(Values=values,?Labels=Labels,?Textinfo=Textinfo,Hole=hole')) |> TraceStyle.TraceInfo(?Name=Name,?Showlegend=Showlegend,?Opacity=Opacity,?Hoverinfo=Hoverinfo) - |> TraceStyle.Marker(?Colors=Colors) + |> TraceStyle.Marker(?Color=Color) |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) |> GenericChart.ofTraceObject @@ -72,7 +72,7 @@ module ChartDomain = static member Doughnut(data:seq<#IConvertible*#IConvertible>, [] ?Name, [] ?Showlegend, - [] ?Colors, + [] ?Color, [] ?Hole, [] ?TextPosition, [] ?TextFont, @@ -80,7 +80,7 @@ module ChartDomain = [] ?Textinfo, [] ?Opacity) = let values,labels = Seq.unzip data - Chart.Doughnut(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Colors=Colors,?Hole=Hole,?TextPosition=TextPosition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity) + Chart.Doughnut(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Color=Color,?Hole=Hole,?TextPosition=TextPosition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity) @@ -194,12 +194,12 @@ module ChartDomain = ///Colors: Sets the color of each sector of this trace. If not specified, the default trace color set is used to pick the sector colors. static member Sunburst(labels,parents, []?Ids, - []?Values , - []?Text , - []?Branchvalues , - []?Level , - []?Maxdepth , - []?Colors: seq, + []?Values, + []?Text, + []?Branchvalues, + []?Level, + []?Maxdepth, + []?Color, []?ColorBar:ColorBar ) = TraceDomain.initSunburst( @@ -214,7 +214,7 @@ module ChartDomain = ?Maxdepth = Maxdepth ) ) - |> TraceStyle.Marker(?Colors=Colors,?ColorBar=ColorBar) + |> TraceStyle.Marker(?Color=Color,?ColorBar=ColorBar) |> GenericChart.ofTraceObject @@ -243,14 +243,14 @@ module ChartDomain = ///Colors: Sets the color of each sector of this trace. If not specified, the default trace color set is used to pick the sector colors. static member Treemap(labels,parents, []?Ids, - []?Values , - []?Text , - []?Branchvalues , - []?Tiling , - []?PathBar , - []?Level , - []?Maxdepth , - []?Colors: seq, + []?Values, + []?Text, + []?Branchvalues, + []?Tiling, + []?PathBar, + []?Level, + []?Maxdepth, + []?Color, []?ColorBar:ColorBar ) = TraceDomain.initTreemap( @@ -267,7 +267,7 @@ module ChartDomain = ?Maxdepth = Maxdepth ) ) - |> TraceStyle.Marker(?Colors=Colors,?ColorBar=ColorBar) + |> TraceStyle.Marker(?Color=Color,?ColorBar=ColorBar) |> GenericChart.ofTraceObject diff --git a/src/Plotly.NET/CommonAbstractions/ColorKeyword.fs b/src/Plotly.NET/CommonAbstractions/ColorKeyword.fs new file mode 100644 index 000000000..7b9918c94 --- /dev/null +++ b/src/Plotly.NET/CommonAbstractions/ColorKeyword.fs @@ -0,0 +1,595 @@ +namespace Plotly.NET + +//https://www.w3.org/TR/2011/REC-SVG11-20110816/types.html#ColorKeywords + +///W3C Recognized color keyword names +type ColorKeyword = + | AliceBlue + | AntiqueWhite + | Aqua + | Aquamarine + | Azure + | Beige + | Bisque + | Black + | BlanchedAlmond + | Blue + | Blueviolet + | Brown + | BurlyWood + | CadetBlue + | Chartreuse + | Chocolate + | Coral + | CornflowerBlue + | CornSilk + | Crimson + | Cyan + | DarkBlue + | DarkCyan + | DarkGoldenRod + | DarkGray + | DarkGreen + | DarkGrey + | DarkKhaki + | DarkMagenta + | Darkolivegreen + | DarkOrange + | DarkOrchid + | DarkRed + | DarkSalmon + | DarkSeaGreen + | DarkSlateBlue + | DarkSlateGray + | DarkSlateGrey + | DarkTurquoise + | DarkViolet + | DeepPink + | DeepSkyBlue + | DimGray + | DimGrey + | DodgerBlue + | FireBrick + | FloralWhite + | ForestGreen + | Fuchsia + | Gainsboro + | GhostWhite + | Gold + | GoldenRod + | Gray + | Grey + | Green + | GreenYellow + | Honeydew + | Hotpink + | IndianRed + | Indigo + | Ivory + | Khaki + | Lavender + | LavenderBlush + | LawnGreen + | LemonChiffon + | LightBlue + | LightCoral + | LightCyan + | LightGoldenRodYellow + | LightGray + | LightGreen + | LightGrey + | LightPink + | LightAalmon + | LightAeaGreen + | LightAkyBlue + | LightAlateGray + | LightslateGrey + | LightSteelBlue + | LightYellow + | Lime + | Limegreen + | Linen + | Magenta + | Maroon + | MediumAquamarine + | MediumBlue + | MediumOrchid + | MediumPurple + | MediumSeaGreen + | MediumSlateBlue + | MediumSpringGreen + | MediumTurquoise + | MediumVioletRed + | MidnightBlue + | MintCream + | MistyRose + | Moccasin + | NavajoWhite + | Navy + | OldLace + | Olive + | OliveDrab + | Orange + | OrangeRed + | Orchid + | PaleGoldenRod + | PaleGreen + | PaleTurquoise + | PaleVioletRed + | PapayaWhip + | PeachPuff + | Peru + | Pink + | Plum + | PowderBlue + | Purple + | Red + | RosyBrown + | RoyalBlue + | SaddleBrown + | Salmon + | SandyBrown + | SeaGreen + | SeaShell + | Sienna + | Silver + | Skyblue + | SlateBlue + | SlateGray + | SlateGrey + | Snow + | SpringGreen + | SteelBlue + | Tan + | Teal + | Thistle + | Tomato + | Turquoise + | Violet + | Wheat + | White + | WhiteSmoke + | Yellow + | YellowGreen + + static member internal ofRGB (r:int) (g:int) (b:int) = + match (r,g,b) with + | (240, 248, 255) -> AliceBlue + | (250, 235, 215) -> AntiqueWhite + | (127, 255, 212) -> Aquamarine + | (240, 255, 255) -> Azure + | (245, 245, 220) -> Beige + | (255, 228, 196) -> Bisque + | ( 0, 0, 0) -> Black + | (255, 235, 205) -> BlanchedAlmond + | ( 0, 0, 255) -> Blue + | (138, 43, 226) -> Blueviolet + | (165, 42, 42) -> Brown + | (222, 184, 135) -> BurlyWood + | ( 95, 158, 160) -> CadetBlue + | (127, 255, 0) -> Chartreuse + | (210, 105, 30) -> Chocolate + | (255, 127, 80) -> Coral + | (100, 149, 237) -> CornflowerBlue + | (255, 248, 220) -> CornSilk + | (220, 20, 60) -> Crimson + | ( 0, 255, 255) -> Cyan + | ( 0, 0, 139) -> DarkBlue + | ( 0, 139, 139) -> DarkCyan + | (184, 134, 11) -> DarkGoldenRod + | ( 0, 100, 0) -> DarkGreen + | (169, 169, 169) -> DarkGray + | (189, 183, 107) -> DarkKhaki + | (139, 0, 139) -> DarkMagenta + | ( 85, 107, 47) -> Darkolivegreen + | (255, 140, 0) -> DarkOrange + | (153, 50, 204) -> DarkOrchid + | (139, 0, 0) -> DarkRed + | (233, 150, 122) -> DarkSalmon + | (143, 188, 143) -> DarkSeaGreen + | ( 72, 61, 139) -> DarkSlateBlue + | ( 47, 79, 79) -> DarkSlateGray + | ( 0, 206, 209) -> DarkTurquoise + | (148, 0, 211) -> DarkViolet + | (255, 20, 147) -> DeepPink + | ( 0, 191, 255) -> DeepSkyBlue + | (105, 105, 105) -> DimGray + | ( 30, 144, 255) -> DodgerBlue + | (178, 34, 34) -> FireBrick + | (255, 250, 240) -> FloralWhite + | ( 34, 139, 34) -> ForestGreen + | (220, 220, 220) -> Gainsboro + | (248, 248, 255) -> GhostWhite + | (255, 215, 0) -> Gold + | (218, 165, 32) -> GoldenRod + | (128, 128, 128) -> Gray + | ( 0, 128, 0) -> Green + | (173, 255, 47) -> GreenYellow + | (240, 255, 240) -> Honeydew + | (255, 105, 180) -> Hotpink + | (205, 92, 92) -> IndianRed + | ( 75, 0, 130) -> Indigo + | (255, 255, 240) -> Ivory + | (240, 230, 140) -> Khaki + | (230, 230, 250) -> Lavender + | (255, 240, 245) -> LavenderBlush + | (124, 252, 0) -> LawnGreen + | (255, 250, 205) -> LemonChiffon + | (173, 216, 230) -> LightBlue + | (240, 128, 128) -> LightCoral + | (224, 255, 255) -> LightCyan + | (250, 250, 210) -> LightGoldenRodYellow + | (211, 211, 211) -> LightGray + | (144, 238, 144) -> LightGreen + | (255, 182, 193) -> LightPink + | (255, 160, 122) -> LightAalmon + | ( 32, 178, 170) -> LightAeaGreen + | (135, 206, 250) -> LightAkyBlue + | (119, 136, 153) -> LightAlateGray + | (176, 196, 222) -> LightSteelBlue + | (255, 255, 224) -> LightYellow + | ( 0, 255, 0) -> Lime + | ( 50, 205, 50) -> Limegreen + | (250, 240, 230) -> Linen + | (255, 0, 255) -> Magenta + | (128, 0, 0) -> Maroon + | (102, 205, 170) -> MediumAquamarine + | ( 0, 0, 205) -> MediumBlue + | (186, 85, 211) -> MediumOrchid + | (147, 112, 219) -> MediumPurple + | ( 60, 179, 113) -> MediumSeaGreen + | (123, 104, 238) -> MediumSlateBlue + | ( 0, 250, 154) -> MediumSpringGreen + | ( 72, 209, 204) -> MediumTurquoise + | (199, 21, 133) -> MediumVioletRed + | ( 25, 25, 112) -> MidnightBlue + | (245, 255, 250) -> MintCream + | (255, 228, 225) -> MistyRose + | (255, 228, 181) -> Moccasin + | (255, 222, 173) -> NavajoWhite + | ( 0, 0, 128) -> Navy + | (253, 245, 230) -> OldLace + | (128, 128, 0) -> Olive + | (107, 142, 35) -> OliveDrab + | (255, 165, 0) -> Orange + | (255, 69, 0) -> OrangeRed + | (218, 112, 214) -> Orchid + | (238, 232, 170) -> PaleGoldenRod + | (152, 251, 152) -> PaleGreen + | (175, 238, 238) -> PaleTurquoise + | (219, 112, 147) -> PaleVioletRed + | (255, 239, 213) -> PapayaWhip + | (255, 218, 185) -> PeachPuff + | (205, 133, 63) -> Peru + | (255, 192, 203) -> Pink + | (221, 160, 221) -> Plum + | (176, 224, 230) -> PowderBlue + | (128, 0, 128) -> Purple + | (255, 0, 0) -> Red + | (188, 143, 143) -> RosyBrown + | ( 65, 105, 225) -> RoyalBlue + | (139, 69, 19) -> SaddleBrown + | (250, 128, 114) -> Salmon + | (244, 164, 96) -> SandyBrown + | ( 46, 139, 87) -> SeaGreen + | (255, 245, 238) -> SeaShell + | (160, 82, 45) -> Sienna + | (192, 192, 192) -> Silver + | (135, 206, 235) -> Skyblue + | (106, 90, 205) -> SlateBlue + | (112, 128, 144) -> SlateGray + | (255, 250, 250) -> Snow + | ( 0, 255, 127) -> SpringGreen + | ( 70, 130, 180) -> SteelBlue + | (210, 180, 140) -> Tan + | ( 0, 128, 128) -> Teal + | (216, 191, 216) -> Thistle + | (255, 99, 71) -> Tomato + | ( 64, 224, 208) -> Turquoise + | (238, 130, 238) -> Violet + | (245, 222, 179) -> Wheat + | (255, 255, 255) -> White + | (245, 245, 245) -> WhiteSmoke + | (255, 255, 0) -> Yellow + | (154, 205, 50) -> YellowGreen + | _ -> failwith "input color has no standard color keyword" + + static member toRGB = function + | AliceBlue -> (240, 248, 255) + | AntiqueWhite -> (250, 235, 215) + | Aqua -> ( 0, 255, 255) + | Aquamarine -> (127, 255, 212) + | Azure -> (240, 255, 255) + | Beige -> (245, 245, 220) + | Bisque -> (255, 228, 196) + | Black -> ( 0, 0, 0) + | BlanchedAlmond -> (255, 235, 205) + | Blue -> ( 0, 0, 255) + | Blueviolet -> (138, 43, 226) + | Brown -> (165, 42, 42) + | BurlyWood -> (222, 184, 135) + | CadetBlue -> ( 95, 158, 160) + | Chartreuse -> (127, 255, 0) + | Chocolate -> (210, 105, 30) + | Coral -> (255, 127, 80) + | CornflowerBlue -> (100, 149, 237) + | CornSilk -> (255, 248, 220) + | Crimson -> (220, 20, 60) + | Cyan -> ( 0, 255, 255) + | DarkBlue -> ( 0, 0, 139) + | DarkCyan -> ( 0, 139, 139) + | DarkGoldenRod -> (184, 134, 11) + | DarkGray -> (169, 169, 169) + | DarkGreen -> ( 0, 100, 0) + | DarkGrey -> (169, 169, 169) + | DarkKhaki -> (189, 183, 107) + | DarkMagenta -> (139, 0, 139) + | Darkolivegreen -> ( 85, 107, 47) + | DarkOrange -> (255, 140, 0) + | DarkOrchid -> (153, 50, 204) + | DarkRed -> (139, 0, 0) + | DarkSalmon -> (233, 150, 122) + | DarkSeaGreen -> (143, 188, 143) + | DarkSlateBlue -> ( 72, 61, 139) + | DarkSlateGray -> ( 47, 79, 79) + | DarkSlateGrey -> ( 47, 79, 79) + | DarkTurquoise -> ( 0, 206, 209) + | DarkViolet -> (148, 0, 211) + | DeepPink -> (255, 20, 147) + | DeepSkyBlue -> ( 0, 191, 255) + | DimGray -> (105, 105, 105) + | DimGrey -> (105, 105, 105) + | DodgerBlue -> ( 30, 144, 255) + | FireBrick -> (178, 34, 34) + | FloralWhite -> (255, 250, 240) + | ForestGreen -> ( 34, 139, 34) + | Fuchsia -> (255, 0, 255) + | Gainsboro -> (220, 220, 220) + | GhostWhite -> (248, 248, 255) + | Gold -> (255, 215, 0) + | GoldenRod -> (218, 165, 32) + | Gray -> (128, 128, 128) + | Grey -> (128, 128, 128) + | Green -> ( 0, 128, 0) + | GreenYellow -> (173, 255, 47) + | Honeydew -> (240, 255, 240) + | Hotpink -> (255, 105, 180) + | IndianRed -> (205, 92, 92) + | Indigo -> ( 75, 0, 130) + | Ivory -> (255, 255, 240) + | Khaki -> (240, 230, 140) + | Lavender -> (230, 230, 250) + | LavenderBlush -> (255, 240, 245) + | LawnGreen -> (124, 252, 0) + | LemonChiffon -> (255, 250, 205) + | LightBlue -> (173, 216, 230) + | LightCoral -> (240, 128, 128) + | LightCyan -> (224, 255, 255) + | LightGoldenRodYellow -> (250, 250, 210) + | LightGray -> (211, 211, 211) + | LightGreen -> (144, 238, 144) + | LightGrey -> (211, 211, 211) + | LightPink -> (255, 182, 193) + | LightAalmon -> (255, 160, 122) + | LightAeaGreen -> ( 32, 178, 170) + | LightAkyBlue -> (135, 206, 250) + | LightAlateGray -> (119, 136, 153) + | LightslateGrey -> (119, 136, 153) + | LightSteelBlue -> (176, 196, 222) + | LightYellow -> (255, 255, 224) + | Lime -> ( 0, 255, 0) + | Limegreen -> ( 50, 205, 50) + | Linen -> (250, 240, 230) + | Magenta -> (255, 0, 255) + | Maroon -> (128, 0, 0) + | MediumAquamarine -> (102, 205, 170) + | MediumBlue -> ( 0, 0, 205) + | MediumOrchid -> (186, 85, 211) + | MediumPurple -> (147, 112, 219) + | MediumSeaGreen -> ( 60, 179, 113) + | MediumSlateBlue -> (123, 104, 238) + | MediumSpringGreen -> ( 0, 250, 154) + | MediumTurquoise -> ( 72, 209, 204) + | MediumVioletRed -> (199, 21, 133) + | MidnightBlue -> ( 25, 25, 112) + | MintCream -> (245, 255, 250) + | MistyRose -> (255, 228, 225) + | Moccasin -> (255, 228, 181) + | NavajoWhite -> (255, 222, 173) + | Navy -> ( 0, 0, 128) + | OldLace -> (253, 245, 230) + | Olive -> (128, 128, 0) + | OliveDrab -> (107, 142, 35) + | Orange -> (255, 165, 0) + | OrangeRed -> (255, 69, 0) + | Orchid -> (218, 112, 214) + | PaleGoldenRod -> (238, 232, 170) + | PaleGreen -> (152, 251, 152) + | PaleTurquoise -> (175, 238, 238) + | PaleVioletRed -> (219, 112, 147) + | PapayaWhip -> (255, 239, 213) + | PeachPuff -> (255, 218, 185) + | Peru -> (205, 133, 63) + | Pink -> (255, 192, 203) + | Plum -> (221, 160, 221) + | PowderBlue -> (176, 224, 230) + | Purple -> (128, 0, 128) + | Red -> (255, 0, 0) + | RosyBrown -> (188, 143, 143) + | RoyalBlue -> ( 65, 105, 225) + | SaddleBrown -> (139, 69, 19) + | Salmon -> (250, 128, 114) + | SandyBrown -> (244, 164, 96) + | SeaGreen -> ( 46, 139, 87) + | SeaShell -> (255, 245, 238) + | Sienna -> (160, 82, 45) + | Silver -> (192, 192, 192) + | Skyblue -> (135, 206, 235) + | SlateBlue -> (106, 90, 205) + | SlateGray -> (112, 128, 144) + | SlateGrey -> (112, 128, 144) + | Snow -> (255, 250, 250) + | SpringGreen -> ( 0, 255, 127) + | SteelBlue -> ( 70, 130, 180) + | Tan -> (210, 180, 140) + | Teal -> ( 0, 128, 128) + | Thistle -> (216, 191, 216) + | Tomato -> (255, 99, 71) + | Turquoise -> ( 64, 224, 208) + | Violet -> (238, 130, 238) + | Wheat -> (245, 222, 179) + | White -> (255, 255, 255) + | WhiteSmoke -> (245, 245, 245) + | Yellow -> (255, 255, 0) + | YellowGreen -> (154, 205, 50) + + static member ofKeyWord = function + | "aliceblue" -> AliceBlue + | "antiquewhite" -> AntiqueWhite + | "aqua" -> Aqua + | "aquamarine" -> Aquamarine + | "azure" -> Azure + | "beige" -> Beige + | "bisque" -> Bisque + | "black" -> Black + | "blanchedalmond" -> BlanchedAlmond + | "blue" -> Blue + | "blueviolet" -> Blueviolet + | "brown" -> Brown + | "burlywood" -> BurlyWood + | "cadetblue" -> CadetBlue + | "chartreuse" -> Chartreuse + | "chocolate" -> Chocolate + | "coral" -> Coral + | "cornflowerblue" -> CornflowerBlue + | "cornsilk" -> CornSilk + | "crimson" -> Crimson + | "cyan" -> Cyan + | "darkblue" -> DarkBlue + | "darkcyan" -> DarkCyan + | "darkgoldenrod" -> DarkGoldenRod + | "darkgray" -> DarkGray + | "darkgreen" -> DarkGreen + | "darkgrey" -> DarkGrey + | "darkkhaki" -> DarkKhaki + | "darkmagenta" -> DarkMagenta + | "darkolivegreen" -> Darkolivegreen + | "darkorange" -> DarkOrange + | "darkorchid" -> DarkOrchid + | "darkred" -> DarkRed + | "darksalmon" -> DarkSalmon + | "darkseagreen" -> DarkSeaGreen + | "darkslateblue" -> DarkSlateBlue + | "darkslategray" -> DarkSlateGray + | "darkslategrey" -> DarkSlateGrey + | "darkturquoise" -> DarkTurquoise + | "darkviolet" -> DarkViolet + | "deeppink" -> DeepPink + | "deepskyblue" -> DeepSkyBlue + | "dimgray" -> DimGray + | "dimgrey" -> DimGrey + | "dodgerblue" -> DodgerBlue + | "firebrick" -> FireBrick + | "floralwhite" -> FloralWhite + | "forestgreen" -> ForestGreen + | "fuchsia" -> Fuchsia + | "gainsboro" -> Gainsboro + | "ghostwhite" -> GhostWhite + | "gold" -> Gold + | "goldenrod" -> GoldenRod + | "gray" -> Gray + | "grey" -> Grey + | "green" -> Green + | "greenyellow" -> GreenYellow + | "honeydew" -> Honeydew + | "hotpink" -> Hotpink + | "indianred" -> IndianRed + | "indigo" -> Indigo + | "ivory" -> Ivory + | "khaki" -> Khaki + | "lavender" -> Lavender + | "lavenderblush" -> LavenderBlush + | "lawngreen" -> LawnGreen + | "lemonchiffon" -> LemonChiffon + | "lightblue" -> LightBlue + | "lightcoral" -> LightCoral + | "lightcyan" -> LightCyan + | "lightgoldenrodyellow" -> LightGoldenRodYellow + | "lightgray" -> LightGray + | "lightgreen" -> LightGreen + | "lightgrey" -> LightGrey + | "lightpink" -> LightPink + | "lightsalmon" -> LightAalmon + | "lightseagreen" -> LightAeaGreen + | "lightskyblue" -> LightAkyBlue + | "lightslategray" -> LightAlateGray + | "lightslategrey" -> LightslateGrey + | "lightsteelblue" -> LightSteelBlue + | "lightyellow" -> LightYellow + | "lime" -> Lime + | "limegreen" -> Limegreen + | "linen" -> Linen + | "magenta" -> Magenta + | "maroon" -> Maroon + | "mediumaquamarine" -> MediumAquamarine + | "mediumblue" -> MediumBlue + | "mediumorchid" -> MediumOrchid + | "mediumpurple" -> MediumPurple + | "mediumseagreen" -> MediumSeaGreen + | "mediumslateblue" -> MediumSlateBlue + | "mediumspringgreen" -> MediumSpringGreen + | "mediumturquoise" -> MediumTurquoise + | "mediumvioletred" -> MediumVioletRed + | "midnightblue" -> MidnightBlue + | "mintcream" -> MintCream + | "mistyrose" -> MistyRose + | "moccasin" -> Moccasin + | "navajowhite" -> NavajoWhite + | "navy" -> Navy + | "oldlace" -> OldLace + | "olive" -> Olive + | "olivedrab" -> OliveDrab + | "orange" -> Orange + | "orangered" -> OrangeRed + | "orchid" -> Orchid + | "palegoldenrod" -> PaleGoldenRod + | "palegreen" -> PaleGreen + | "paleturquoise" -> PaleTurquoise + | "palevioletred" -> PaleVioletRed + | "papayawhip" -> PapayaWhip + | "peachpuff" -> PeachPuff + | "peru" -> Peru + | "pink" -> Pink + | "plum" -> Plum + | "powderblue" -> PowderBlue + | "purple" -> Purple + | "red" -> Red + | "rosybrown" -> RosyBrown + | "royalblue" -> RoyalBlue + | "saddlebrown" -> SaddleBrown + | "salmon" -> Salmon + | "sandybrown" -> SandyBrown + | "seagreen" -> SeaGreen + | "seashell" -> SeaShell + | "sienna" -> Sienna + | "silver" -> Silver + | "skyblue" -> Skyblue + | "slateblue" -> SlateBlue + | "slategray" -> SlateGray + | "slategrey" -> SlateGrey + | "snow" -> Snow + | "springgreen" -> SpringGreen + | "steelblue" -> SteelBlue + | "tan" -> Tan + | "teal" -> Teal + | "thistle" -> Thistle + | "tomato" -> Tomato + | "turquoise" -> Turquoise + | "violet" -> Violet + | "wheat" -> Wheat + | "white" -> White + | "whitesmoke" -> WhiteSmoke + | "yellow" -> Yellow + | "yellowgreen" -> YellowGreen + | _ -> failwith "not a valid color keyword" + diff --git a/src/Plotly.NET/CommonAbstractions/Colors.fs b/src/Plotly.NET/CommonAbstractions/Colors.fs index 3576534db..fe78cab65 100644 --- a/src/Plotly.NET/CommonAbstractions/Colors.fs +++ b/src/Plotly.NET/CommonAbstractions/Colors.fs @@ -1,208 +1,228 @@ namespace Plotly.NET //http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/ -/// Represents an ARGB (alpha, red, green, blue) color -module Colors = +open Newtonsoft.Json - module internal Hex = - - open System +module internal Hex = - [] - let toHexDigit n = - if n < 10 then char (n + 0x30) else char (n + 0x37) - - [] - let fromHexDigit c = - if c >= '0' && c <= '9' then int c - int '0' - elif c >= 'A' && c <= 'F' then (int c - int 'A') + 10 - elif c >= 'a' && c <= 'f' then (int c - int 'a') + 10 - else raise <| new ArgumentException() - - // [] - // let encode (buf:byte array) (prefix:bool) = - // let hex = Array.zeroCreate (buf.Length * 2) - // let mutable n = 0 - // for i = 0 to buf.Length - 1 do - // hex.[n] <- toHexDigit ((int buf.[i] &&& 0xF0) >>> 4) - // n <- n + 1 - // hex.[n] <- toHexDigit (int buf.[i] &&& 0xF) - // n <- n + 1 - // if prefix then String.Concat("0x", new String(hex)) - // else new String(hex) - [] - let encode (prefix:string) (color:byte array) = - let hex = Array.zeroCreate (color.Length * 2) - let mutable n = 0 - for i = 0 to color.Length - 1 do - hex.[n] <- toHexDigit ((int color.[i] &&& 0xF0) >>> 4) - n <- n + 1 - hex.[n] <- toHexDigit (int color.[i] &&& 0xF) - n <- n + 1 - String.Concat(prefix, new String(hex)) - - - [] - let decode (s:string) = - match s with - | null -> nullArg "s" - | _ when s.Length = 0 -> Array.empty - | _ -> - let mutable len = s.Length - let mutable i = 0 - if len >= 2 && s.[0] = '0' && (s.[1] = 'x' || s.[1] = 'X') then do - len <- len - 2 - i <- i + 2 - if len % 2 <> 0 then invalidArg "s" "Invalid hex format" - else - let buf = Array.zeroCreate (len / 2) - let mutable n = 0 - while i < s.Length do - buf.[n] <- byte (((fromHexDigit s.[i]) <<< 4) ||| (fromHexDigit s.[i + 1])) - i <- i + 2 - n <- n + 1 - buf + open System + [] + let toHexDigit n = + if n < 10 then char (n + 0x30) else char (n + 0x37) + + [] + let fromHexDigit c = + if c >= '0' && c <= '9' then int c - int '0' + elif c >= 'A' && c <= 'F' then (int c - int 'A') + 10 + elif c >= 'a' && c <= 'f' then (int c - int 'a') + 10 + else raise <| ArgumentException() - /// Color component ARGB - type ColorComponent = - | A of byte - | R of byte - | G of byte - | B of byte - - let getValueFromCC cc = - match cc with - | A v -> v - | R v -> v - | G v -> v - | B v -> v - - /// Color structure - type Color = { - /// The alpha component value of this Color structure. - A : byte - /// The red component value of this Color structure. - R : byte - /// The green component value of this Color structure. - G : byte - /// The blue component value of this Color structure. - B : byte - } - + + [] + let encode (prefix:string) (color:byte array) = + let hex = Array.zeroCreate (color.Length * 2) + let mutable n = 0 + for i = 0 to color.Length - 1 do + hex.[n] <- toHexDigit ((int color.[i] &&& 0xF0) >>> 4) + n <- n + 1 + hex.[n] <- toHexDigit (int color.[i] &&& 0xF) + n <- n + 1 + String.Concat(prefix, String(hex)) - let maxRGB c = - let r,g,b = R c.R,G c.G,B c.B - max r g |> max b + + [] + let decode (s:string) = + match s with + | null -> nullArg "s" + | _ when s.Length = 0 -> Array.empty + | _ -> + let mutable len = s.Length + let mutable i = 0 + if len >= 2 && s.[0] = '0' && (s.[1] = 'x' || s.[1] = 'X') then do + len <- len - 2 + i <- i + 2 + if len % 2 <> 0 then invalidArg "s" "Invalid hex format" + else + let buf = Array.zeroCreate (len / 2) + let mutable n = 0 + while i < s.Length do + buf.[n] <- byte (((fromHexDigit s.[i]) <<< 4) ||| (fromHexDigit s.[i + 1])) + i <- i + 2 + n <- n + 1 + buf - let minRGB c = - let r,g,b = R c.R,G c.G,B c.B - min r g |> min b - - /// Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. - let fromArgb a r g b = - let f v = +/// Represents an ARGB (alpha, red, green, blue) color +[)>] +type ARGB = { + /// The alpha component value of this Color structure. + A : byte + /// The red component value of this Color structure. + R : byte + /// The green component value of this Color structure. + G : byte + /// The blue component value of this Color structure. + B : byte + } with + + /// Creates a Argb Color from the four ARGB component (alpha, red, green, and blue) values. + static member create a r g b = + let fi v = if v < 0 || v > 255 then failwithf "Value for component needs to be between 0 and 255." else byte v - {A= f a; R = f r; G = f g; B = f b} + {A= fi a; R = fi r; G = fi g; B = fi b} - /// Creates a Color structure from the specified color values (red, green, and blue). + /// Creates a Argb color from the specified color values (red, green, and blue). /// The alpha value is implicitly 255 (fully opaque). - let fromRgb r g b = - fromArgb 255 r g b - -// /// Gets the hue-saturation-brightness (HSB) brightness value for this Color structure. -// let getBrightness = () - - /// Gets the hue-saturation-brightness (HSB) hue value, in degrees, for this Color structure. - let getHue c = - let min = minRGB c |> getValueFromCC - match maxRGB c with - | R r -> float (c.G - c.B) / float (r - min) - | G g -> 2.0 + float (c.B - c. R) / float (g - min) - | B b -> 4.0 + float (c.R - c.G) / float (b - min) - | _ -> failwithf "" // can't be - - - /// Gets the hue-saturation-brightness (HSB) saturation value for this Color structure. - let getSaturation col = - let minimum = minRGB col - let maximum = maxRGB col - float (getValueFromCC minimum + getValueFromCC maximum) / 2. - |> round - - /// Gets the 32-bit ARGB value of this Color structure. - let toArgb c = - (int c.A, int c.R, int c.G, int c.B) - + static member fromRGB r g b = + ARGB.create 255 r g b + /// Gets the hex representataion (FFFFFF) of a color (with valid prefix "0xFFFFFF") - let toHex prefix (c:Color) = + static member toHex prefix (c:ARGB) = let prefix' = if prefix then "0x" else "" Hex.encode prefix' [|c.R;c.G;c.B|] /// Gets color from hex representataion (FFFFFF) or (0xFFFFFF) - let fromHex (s:string) = + static member fromHex (s:string) = match (Hex.decode s) with - | [|r;g;b|] -> fromRgb (int r) (int g) (int b) + | [|r;g;b|] -> ARGB.fromRGB (int r) (int g) (int b) | _ -> failwithf "Invalid hex color format" /// Gets the web color representataion (#FFFFFF) - let toWebColor c = + static member toWebHex c = Hex.encode "#" [|c.R;c.G;c.B|] /// Gets color from web color (#FFFFFF) - let fromWebColor (s:string) = + static member fromWebHex (s:string) = let s' = s.TrimStart([|'#'|]) match (Hex.decode s') with - | [|r;g;b|] -> fromRgb (int r) (int g) (int b) + | [|r;g;b|] -> ARGB.fromRGB (int r) (int g) (int b) | _ -> failwithf "Invalid hex color format" - /// Converts this Color structure to a human-readable string. - let toString c = - let a,r,g,b = toArgb c + static member toString c = + let a,r,g,b = (int c.A, int c.R, int c.G, int c.B) sprintf "{Alpha: %i Red: %i Green: %i Blue: %i}" a r g b + static member fromKeyword (c:ColorKeyword) = + c + |> ColorKeyword.toRGB + |> fun (r,g,b) -> ARGB.fromRGB r g b + +and ARGBConverter() = + inherit JsonConverter() + + override _.CanConvert(objectType) = + objectType = typeof + + override _.ReadJson(reader, t, existingValue, serializer) = + raise (System.NotImplementedException()) + //unbox reader.Value + + override _.WriteJson(writer, value, serializer) = + let argb = value :?> ARGB + //writer.WriteValue(sprintf "rgba(%i, %i, %i, %0.1f)" argb.R argb.G argb.B argb.A ) + writer.WriteValue(sprintf "rgba(%i, %i, %i, %0.1f)" argb.R argb.G argb.B (float argb.A / 255.)) + +/// Plotly color can be a single color, a sequence of colors, or a sequence of numeric values referencing the color of the colorscale obj +[)>] +type Color private(obj:obj) = - // http://graphicdesign.stackexchange.com/questions/3682/where-can-i-find-a-large-palette-set-of-contrasting-colors-for-coloring-many-d + /// Creates a Color from the four ARGB component (alpha, red, green, and blue) values. + static member fromARGB a r g b = + ARGB.create a r g b + |> unbox + |> Color + + /// Creates a Color from the specified color values (red, green, and blue). + /// The alpha value is implicitly 1. (fully opaque). + static member fromRGB r g b = + Color.fromARGB 255 r g b + + /// Color from web color (#FFFFFF) or hex representataion (FFFFFF) / (0xFFFFFF) + static member fromHex (s:string) = + let s' = s.TrimStart('#') + match (Hex.decode s') with + | [|r;g;b|] -> Color.fromRGB (int r) (int g) (int b) + | _ -> failwithf "Invalid hex color format" + + /// Color + static member fromColors (c:seq) = + let tmp = + c |> Seq.map (fun v -> v.Value) + Color (unbox tmp) + + /// Color from a raw string input, no check for correctness performed + static member fromString (c:string) = + Color (unbox c) + + /// Values are interpreted relative to color scale + static member fromColorScaleValues (c:seq) = + Color (unbox c) + + /// Color from a standard web color keyword, e.g. White -> "white" (see //https://www.w3.org/TR/2011/REC-SVG11-20110816/types.html#ColorKeywords) + static member fromKeyword (c: ColorKeyword) = + Color (unbox (ARGB.fromKeyword c)) + + + /// extractor + member this.Value = obj + +and ColorConverter() = + inherit JsonConverter() + + override _.CanConvert(objectType) = + objectType = typeof + + override _.ReadJson(reader, t, existingValue, serializer) = + raise (System.NotImplementedException()) + + override _.WriteJson(writer, value, serializer) = + let c = value :?> Color + let jc = JsonConvert.SerializeObject(c.Value) + writer.WriteRawValue(jc) + + +// http://graphicdesign.stackexchange.com/questions/3682/where-can-i-find-a-large-palette-set-of-contrasting-colors-for-coloring-many-d +module Color = module Table = - let black = fromRgb 0 0 0 - let blackLite = fromRgb 89 89 89 // 35% lighter - let white = fromRgb 255 255 255 + let black = Color.fromRGB 0 0 0 + let blackLite = Color.fromRGB 89 89 89 // 35% lighter + let white = Color.fromRGB 255 255 255 /// Color palette from Microsoft office 2016 module Office = - + // blue - let blue = fromRgb 65 113 156 - let lightBlue = fromRgb 189 215 238 - let darkBlue = fromRgb 68 114 196 - + let blue = Color.fromRGB 65 113 156 + let lightBlue = Color.fromRGB 189 215 238 + let darkBlue = Color.fromRGB 68 114 196 + // red - let red = fromRgb 241 90 96 - let lightRed = fromRgb 252 212 214 + let red = Color.fromRGB 241 90 96 + let lightRed = Color.fromRGB 252 212 214 // orange - let orange = fromRgb 237 125 49 - let lightOrange = fromRgb 248 203 173 - + let orange = Color.fromRGB 237 125 49 + let lightOrange = Color.fromRGB 248 203 173 + // yellow - let yellow = fromRgb 255 217 102 - let lightYellow = fromRgb 255 230 153 - let darkYellow = fromRgb 255 192 0 - + let yellow = Color.fromRGB 255 217 102 + let lightYellow = Color.fromRGB 255 230 153 + let darkYellow = Color.fromRGB 255 192 0 + // green - let green = fromRgb 122 195 106 - let lightGreen = fromRgb 197 224 180 - let darkGreen = fromRgb 112 173 71 + let green = Color.fromRGB 122 195 106 + let lightGreen = Color.fromRGB 197 224 180 + let darkGreen = Color.fromRGB 112 173 71 // grey - let grey = fromRgb 165 165 165 - let lightGrey = fromRgb 217 217 217 + let grey = Color.fromRGB 165 165 165 + let lightGrey = Color.fromRGB 217 217 217 // From publication: Escaping RGBland: Selecting Colors for Statistical Graphics // http://epub.wu.ac.at/1692/1/document.pdf diff --git a/src/Plotly.NET/CommonAbstractions/Font.fs b/src/Plotly.NET/CommonAbstractions/Font.fs index c3efeb08e..7888f2c7d 100644 --- a/src/Plotly.NET/CommonAbstractions/Font.fs +++ b/src/Plotly.NET/CommonAbstractions/Font.fs @@ -10,9 +10,9 @@ type Font () = /// Init Font() static member init ( - [] ?Family : StyleParam.FontFamily, - [] ?Size : float, - [] ?Color : string + [] ?Family, + [] ?Size, + [] ?Color ) = Font() |> Font.style @@ -28,7 +28,7 @@ type Font () = ( [] ?Family: StyleParam.FontFamily, [] ?Size: float, - [] ?Color: string + [] ?Color: Color ) = (fun (font:Font) -> diff --git a/src/Plotly.NET/CommonAbstractions/Line.fs b/src/Plotly.NET/CommonAbstractions/Line.fs index b2138fc73..97ce39de2 100644 --- a/src/Plotly.NET/CommonAbstractions/Line.fs +++ b/src/Plotly.NET/CommonAbstractions/Line.fs @@ -11,14 +11,14 @@ type Line () = /// Initialized Line object static member init ( - [] ?Width:float, - [] ?Color:string, - [] ?Shape:StyleParam.Shape, - [] ?Dash:StyleParam.DrawingStyle, - [] ?Smoothing:float, - [] ?Colorscale:StyleParam.Colorscale, - [] ?OutlierColor:string, - [] ?OutlierWidth:float + [] ?Width, + [] ?Color, + [] ?Shape, + [] ?Dash, + [] ?Smoothing, + [] ?Colorscale, + [] ?OutlierColor, + [] ?OutlierWidth ) = Line () @@ -39,12 +39,12 @@ type Line () = static member style ( [] ?Width:float, - [] ?Color:string, + [] ?Color:Color, [] ?Shape:StyleParam.Shape, [] ?Dash:StyleParam.DrawingStyle, [] ?Smoothing:float, [] ?Colorscale:StyleParam.Colorscale, - [] ?OutlierColor:string, + [] ?OutlierColor:Color, [] ?OutlierWidth:float ) = diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/Annotation.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/Annotation.fs index 4bd198517..423627ad3 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/Annotation.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/Annotation.fs @@ -14,27 +14,27 @@ type Annotation() = ( X : System.IConvertible, Y : System.IConvertible, - [] ?XRef : System.IConvertible, - [] ?YRef : System.IConvertible, - [] ?ArrowTailX : float, - [] ?ArrowTailY : float, - [] ?ShowArrow : bool, - [] ?ArrowColor : string, - [] ?ArrowHead : StyleParam.ArrowHead, - [] ?ArrowSize : float, - [] ?ArrowWidth : float, - [] ?Z : float, - [] ?Text : string, - [] ?TextAngle : float, - [] ?Font : Font, - [] ?Width : float, - [] ?Height : float, - [] ?Opacity : float, - [] ?HorizontalAlign: StyleParam.HorizontalAlign, - [] ?VerticalAlign : StyleParam.VerticalAlign, - [] ?BGColor : string, - [] ?BorderColor : string, - [] ?Visible : bool + [] ?XRef , + [] ?YRef , + [] ?ArrowTailX , + [] ?ArrowTailY , + [] ?ShowArrow , + [] ?ArrowColor , + [] ?ArrowHead , + [] ?ArrowSize , + [] ?ArrowWidth , + [] ?Z , + [] ?Text , + [] ?TextAngle , + [] ?Font , + [] ?Width , + [] ?Height , + [] ?Opacity , + [] ?HorizontalAlign, + [] ?VerticalAlign , + [] ?BGColor , + [] ?BorderColor , + [] ?Visible ) = Annotation() |> Annotation.style @@ -86,8 +86,8 @@ type Annotation() = [] ?Opacity : float, [] ?HorizontalAlign: StyleParam.HorizontalAlign, [] ?VerticalAlign : StyleParam.VerticalAlign, - [] ?BGColor : string, - [] ?BorderColor : string, + [] ?BGColor : Color, + [] ?BorderColor : Color, [] ?Visible : bool ) = diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/Shape.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/Shape.fs index be27fc428..056cb4ab0 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/Shape.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/Shape.fs @@ -12,18 +12,18 @@ type Shape () = /// Init Shape type static member init ( - [] ?ShapeType: StyleParam.ShapeType, - [] ?X0: #IConvertible, - [] ?X1: #IConvertible, - [] ?Y0: #IConvertible, - [] ?Y1: #IConvertible, - [] ?Path: string, - [] ?Opacity: float, - [] ?Line: Line, - [] ?Fillcolor: string , - [] ?Layer: StyleParam.Layer, - [] ?Xref: string, - [] ?Yref: string + [] ?ShapeType, + [] ?X0, + [] ?X1, + [] ?Y0, + [] ?Y1, + [] ?Path, + [] ?Opacity, + [] ?Line, + [] ?Fillcolor, + [] ?Layer, + [] ?Xref, + [] ?Yref ) = Shape() |> Shape.style @@ -53,7 +53,7 @@ type Shape () = [] ?Path: string, [] ?Opacity: float, [] ?Line: Line, - [] ?Fillcolor: string , + [] ?Fillcolor: Color, [] ?Layer: StyleParam.Layer, [] ?Xref: string, [] ?Yref: string diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Map/Geo.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Map/Geo.fs index b5b5823a0..a1e4e41fc 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Map/Geo.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Map/Geo.fs @@ -44,37 +44,37 @@ type Geo() = /// Sets the longitudinal axis for this geo trace static member init ( - [] ?FitBounds: StyleParam.GeoFitBounds, - [] ?Resolution: StyleParam.GeoResolution, - [] ?Scope: StyleParam.GeoScope, - [] ?Projection: GeoProjection, - [] ?Center: (float*float), - [] ?Visible: bool, - [] ?Domain: Domain, - [] ?ShowCoastLines: bool, - [] ?CoastLineColor: string, - [] ?CoastLineWidth: float, - [] ?ShowLand: bool, - [] ?LandColor: string, - [] ?ShowOcean: bool, - [] ?OceanColor: string, - [] ?ShowLakes: bool, - [] ?LakeColor: string, - [] ?ShowRivers: bool, - [] ?RiverColor: string, - [] ?RiverWidth: float, - [] ?ShowCountries: bool, - [] ?CountryColor: string, - [] ?CountryWidth: float, - [] ?ShowSubunits: bool, - [] ?SubunitColor: string, - [] ?SubunitWidth: float, - [] ?ShowFrame: bool, - [] ?FrameColor: string, - [] ?FrameWidth: float, - [] ?BgColor: string, - [] ?LatAxis: LinearAxis, - [] ?LonAxis: LinearAxis + [] ?FitBounds, + [] ?Resolution, + [] ?Scope, + [] ?Projection, + [] ?Center, + [] ?Visible, + [] ?Domain, + [] ?ShowCoastLines, + [] ?CoastLineColor, + [] ?CoastLineWidth, + [] ?ShowLand, + [] ?LandColor, + [] ?ShowOcean, + [] ?OceanColor, + [] ?ShowLakes, + [] ?LakeColor, + [] ?ShowRivers, + [] ?RiverColor, + [] ?RiverWidth, + [] ?ShowCountries, + [] ?CountryColor, + [] ?CountryWidth, + [] ?ShowSubunits, + [] ?SubunitColor, + [] ?SubunitWidth, + [] ?ShowFrame, + [] ?FrameColor, + [] ?FrameWidth, + [] ?BgColor, + [] ?LatAxis, + [] ?LonAxis ) = Geo() @@ -155,27 +155,27 @@ type Geo() = [] ?Visible: bool, [] ?Domain: Domain, [] ?ShowCoastLines: bool, - [] ?CoastLineColor: string, + [] ?CoastLineColor: Color, [] ?CoastLineWidth: float, [] ?ShowLand: bool, - [] ?LandColor: string, + [] ?LandColor: Color, [] ?ShowOcean: bool, - [] ?OceanColor: string, + [] ?OceanColor: Color, [] ?ShowLakes: bool, - [] ?LakeColor: string, + [] ?LakeColor: Color, [] ?ShowRivers: bool, - [] ?RiverColor: string, + [] ?RiverColor: Color, [] ?RiverWidth: float, [] ?ShowCountries: bool, - [] ?CountryColor: string, + [] ?CountryColor: Color, [] ?CountryWidth: float, [] ?ShowSubunits: bool, - [] ?SubunitColor: string, + [] ?SubunitColor: Color, [] ?SubunitWidth: float, [] ?ShowFrame: bool, - [] ?FrameColor: string, + [] ?FrameColor: Color, [] ?FrameWidth: float, - [] ?BgColor: string, + [] ?BgColor: Color, [] ?LatAxis: LinearAxis, [] ?LonAxis: LinearAxis ) = diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Polar/AngularAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Polar/AngularAxis.fs index b84458479..c7c09aa74 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Polar/AngularAxis.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Polar/AngularAxis.fs @@ -57,48 +57,48 @@ type AngularAxis () = /// Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis. static member init ( - [] ?Visible : bool, - [] ?AxisType : StyleParam.AxisType, - [] ?AutoTypeNumbers : StyleParam.AutoTypeNumbers, - [] ?CategoryOrder : StyleParam.CategoryOrder, - [] ?CategoryArray : seq<#IConvertible>, - [] ?ThetaUnit : StyleParam.AngularUnit, - [] ?Period : float, - [] ?Direction : StyleParam.Direction, - [] ?Rotation : int, - [] ?HoverFormat : string, - [] ?UIRevision : #IConvertible, - [] ?Color : string, - [] ?ShowLine : bool, - [] ?LineColor : string, - [] ?LineWidth : int, - [] ?ShowGrid : bool, - [] ?GridColor : string, - [] ?GridWidth : int, - [] ?TickMode : StyleParam.TickMode, - [] ?NTicks : int, - [] ?Tick0 : #IConvertible, - [] ?DTick : #IConvertible, - [] ?TickVals : seq<#IConvertible>, - [] ?TickText : seq<#IConvertible>, - [] ?Ticks : StyleParam.TickOptions, - [] ?TickLen : int, - [] ?TickWidth : int, - [] ?TickColor : string, - [] ?ShowTickLabels : bool, - [] ?ShowTickPrefix : StyleParam.ShowTickOption, - [] ?TickPrefix : string, - [] ?ShowTickSuffix : StyleParam.ShowTickOption, - [] ?TickSuffix : string, - [] ?ShowExponent : StyleParam.ShowExponent, - [] ?ExponentFormat : StyleParam.ExponentFormat, - [] ?MinExponent : float, - [] ?SeparateThousands : bool, - [] ?TickFont : Font, - [] ?TickAngle : int, - [] ?TickFormat : string, - [] ?TickFormatStops : seq, - [] ?Layer : StyleParam.Layer + [] ?Visible , + [] ?AxisType , + [] ?AutoTypeNumbers , + [] ?CategoryOrder , + [] ?CategoryArray , + [] ?ThetaUnit , + [] ?Period , + [] ?Direction , + [] ?Rotation , + [] ?HoverFormat , + [] ?UIRevision , + [] ?Color , + [] ?ShowLine , + [] ?LineColor , + [] ?LineWidth , + [] ?ShowGrid , + [] ?GridColor , + [] ?GridWidth , + [] ?TickMode , + [] ?NTicks , + [] ?Tick0 , + [] ?DTick , + [] ?TickVals , + [] ?TickText , + [] ?Ticks , + [] ?TickLen , + [] ?TickWidth , + [] ?TickColor , + [] ?ShowTickLabels , + [] ?ShowTickPrefix , + [] ?TickPrefix , + [] ?ShowTickSuffix , + [] ?TickSuffix , + [] ?ShowExponent , + [] ?ExponentFormat , + [] ?MinExponent , + [] ?SeparateThousands , + [] ?TickFont , + [] ?TickAngle , + [] ?TickFormat , + [] ?TickFormatStops , + [] ?Layer ) = AngularAxis() |> AngularAxis.style @@ -205,12 +205,12 @@ type AngularAxis () = [] ?Rotation : int, [] ?HoverFormat : string, [] ?UIRevision : #IConvertible, - [] ?Color : string, + [] ?Color : Color, [] ?ShowLine : bool, - [] ?LineColor : string, + [] ?LineColor : Color, [] ?LineWidth : int, [] ?ShowGrid : bool, - [] ?GridColor : string, + [] ?GridColor : Color, [] ?GridWidth : int, [] ?TickMode : StyleParam.TickMode, [] ?NTicks : int, @@ -221,7 +221,7 @@ type AngularAxis () = [] ?Ticks : StyleParam.TickOptions, [] ?TickLen : int, [] ?TickWidth : int, - [] ?TickColor : string, + [] ?TickColor : Color, [] ?ShowTickLabels : bool, [] ?ShowTickPrefix : StyleParam.ShowTickOption, [] ?TickPrefix : string, diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Polar/RadialAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Polar/RadialAxis.fs index 9704372c2..202a3dd20 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Polar/RadialAxis.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Polar/RadialAxis.fs @@ -59,51 +59,51 @@ type RadialAxis () = /// Sets the calendar system to use for `range` and `tick0` if this is a date axis. This does not set the calendar for interpreting data on this axis, that's specified in the trace or via the global `layout.calendar` static member init ( - [] ?Visible : bool, - [] ?AxisType : StyleParam.AxisType, - [] ?AutoTypeNumbers : StyleParam.AutoTypeNumbers, - [] ?AutoRange : StyleParam.AutoRange, - [] ?RangeMode : StyleParam.RangeMode, - [] ?Range : StyleParam.Range, - [] ?CategoryOrder : StyleParam.CategoryOrder, - [] ?CategoryArray : seq<#IConvertible>, - [] ?Angle : float, - [] ?Side : StyleParam.Direction, - [] ?Title : Title, - [] ?HoverFormat : string, - [] ?UIRevision : #IConvertible, - [] ?Color : string, - [] ?ShowLine : bool, - [] ?LineColor : string, - [] ?LineWidth : int, - [] ?ShowGrid : bool, - [] ?GridColor : string, - [] ?GridWidth : int, - [] ?TickMode : StyleParam.TickMode, - [] ?NTicks : int, - [] ?Tick0 : #IConvertible, - [] ?DTick : #IConvertible, - [] ?TickVals : seq<#IConvertible>, - [] ?TickText : seq<#IConvertible>, - [] ?Ticks : StyleParam.TickOptions, - [] ?TickLen : int, - [] ?TickWidth : int, - [] ?TickColor : string, - [] ?ShowTickLabels : bool, - [] ?ShowTickPrefix : StyleParam.ShowTickOption, - [] ?TickPrefix : string, - [] ?ShowTickSuffix : StyleParam.ShowTickOption, - [] ?TickSuffix : string, - [] ?ShowExponent : StyleParam.ShowExponent, - [] ?ExponentFormat : StyleParam.ExponentFormat, - [] ?MinExponent : float, - [] ?SeparateThousands : bool, - [] ?TickFont : Font, - [] ?TickAngle : int, - [] ?TickFormat : string, - [] ?TickFormatStops : seq, - [] ?Layer : StyleParam.Layer, - [] ?Calendar : StyleParam.Calendar + [] ?Visible , + [] ?AxisType , + [] ?AutoTypeNumbers , + [] ?AutoRange , + [] ?RangeMode , + [] ?Range , + [] ?CategoryOrder , + [] ?CategoryArray , + [] ?Angle , + [] ?Side , + [] ?Title , + [] ?HoverFormat , + [] ?UIRevision , + [] ?Color , + [] ?ShowLine , + [] ?LineColor , + [] ?LineWidth , + [] ?ShowGrid , + [] ?GridColor , + [] ?GridWidth , + [] ?TickMode , + [] ?NTicks , + [] ?Tick0 , + [] ?DTick , + [] ?TickVals , + [] ?TickText , + [] ?Ticks , + [] ?TickLen , + [] ?TickWidth , + [] ?TickColor , + [] ?ShowTickLabels , + [] ?ShowTickPrefix , + [] ?TickPrefix , + [] ?ShowTickSuffix , + [] ?TickSuffix , + [] ?ShowExponent , + [] ?ExponentFormat , + [] ?MinExponent , + [] ?SeparateThousands , + [] ?TickFont , + [] ?TickAngle , + [] ?TickFormat , + [] ?TickFormatStops , + [] ?Layer , + [] ?Calendar ) = RadialAxis() |> RadialAxis.style @@ -218,12 +218,12 @@ type RadialAxis () = [] ?Title : Title, [] ?HoverFormat : string, [] ?UIRevision : #IConvertible, - [] ?Color : string, + [] ?Color : Color, [] ?ShowLine : bool, - [] ?LineColor : string, + [] ?LineColor : Color, [] ?LineWidth : int, [] ?ShowGrid : bool, - [] ?GridColor : string, + [] ?GridColor : Color, [] ?GridWidth : int, [] ?TickMode : StyleParam.TickMode, [] ?NTicks : int, @@ -234,7 +234,7 @@ type RadialAxis () = [] ?Ticks : StyleParam.TickOptions, [] ?TickLen : int, [] ?TickWidth : int, - [] ?TickColor : string, + [] ?TickColor : Color, [] ?ShowTickLabels : bool, [] ?ShowTickPrefix : StyleParam.ShowTickOption, [] ?TickPrefix : string, diff --git a/src/Plotly.NET/Plotly.NET.fsproj b/src/Plotly.NET/Plotly.NET.fsproj index abc4cb019..4851b7107 100644 --- a/src/Plotly.NET/Plotly.NET.fsproj +++ b/src/Plotly.NET/Plotly.NET.fsproj @@ -35,6 +35,7 @@ + diff --git a/src/Plotly.NET/Template/Template.fs b/src/Plotly.NET/Template/Template.fs index 1d965a2c8..bdf19d37e 100644 --- a/src/Plotly.NET/Template/Template.fs +++ b/src/Plotly.NET/Template/Template.fs @@ -137,7 +137,7 @@ module ChartTemplates = Layout.init( PaperBGColor = "rgb(55, 55, 61)", PlotBGColor= "rgb(55, 55, 61)", - Font = Font.init(Color = "rgb(204, 204, 204)") + Font = Font.init(Color = Color.fromString "rgb(204, 204, 204)") ) |> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initDarkAxisTemplate())) |> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initDarkAxisTemplate())) @@ -175,7 +175,7 @@ module ChartTemplates = Layout.init( PaperBGColor = "#200117", PlotBGColor= "#200117", - Font = Font.init(Color = "white") + Font = Font.init(Color = Color.fromString "white") ) |> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initFslabAxisTemplate())) |> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initFslabAxisTemplate())) diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs index d1bc30f69..56dc6cec0 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs @@ -13,27 +13,27 @@ type Marker () = /// Initialized Marker object static member init ( - [] ?Size: int, - [] ?Opacity: float, - [] ?Color: string, - [] ?Symbol: StyleParam.Symbol, - [] ?MultiSizes: seq<#IConvertible>, - [] ?Line: Line, - [] ?ColorBar: ColorBar, - [] ?Colorscale : StyleParam.Colorscale, - [] ?Colors: seq, - [] ?OutlierColor:string, - [] ?Maxdisplayed: int, - [] ?Sizeref: float, - [] ?Sizemin: float, - [] ?Sizemode: StyleParam.MarkerSizeMode, - [] ?Cauto: bool, - [] ?Cmax: float, - [] ?Cmin: float, - [] ?Cmid: float, - [] ?Autocolorscale: bool, - [] ?Reversescale: bool, - [] ?Showscale: bool + [] ?Size, + [] ?Opacity, + [] ?Color, + [] ?Symbol, + [] ?MultiSizes, + [] ?Line, + [] ?ColorBar, + [] ?Colorscale, + //[] ?Colors: seq, + [] ?OutlierColor, + [] ?Maxdisplayed, + [] ?Sizeref, + [] ?Sizemin, + [] ?Sizemode, + [] ?Cauto, + [] ?Cmax, + [] ?Cmin, + [] ?Cmid, + [] ?Autocolorscale, + [] ?Reversescale, + [] ?Showscale ) = Marker () @@ -47,7 +47,7 @@ type Marker () = ?Line = Line , ?ColorBar = ColorBar , ?Colorscale = Colorscale , - ?Colors = Colors , + //?Colors = Colors , ?OutlierColor = OutlierColor , ?Maxdisplayed = Maxdisplayed , @@ -68,14 +68,14 @@ type Marker () = ( [] ?Size: int, [] ?Opacity: float, - [] ?Color: string, + [] ?Color: Color, [] ?Symbol: StyleParam.Symbol, [] ?MultiSizes: seq<#IConvertible>, [] ?Line: Line, [] ?ColorBar: ColorBar, [] ?Colorscale : StyleParam.Colorscale, - [] ?Colors: seq, - [] ?OutlierColor:string, + //[] ?Colors: seq, + [] ?OutlierColor:Color, [] ?Maxdisplayed: int, [] ?Sizeref: float, [] ?Sizemin: float, @@ -97,7 +97,7 @@ type Marker () = Line |> DynObj.setValueOpt marker "line" ColorBar |> DynObj.setValueOpt marker "colorbar" Colorscale |> DynObj.setValueOptBy marker "colorscale" StyleParam.Colorscale.convert - Colors |> DynObj.setValueOpt marker "colors" + //Colors |> DynObj.setValueOpt marker "colors" OutlierColor |> DynObj.setValueOpt marker "outliercolor" Maxdisplayed |> DynObj.setValueOpt marker "maxdisplayed" Sizeref |> DynObj.setValueOpt marker "sizeref" diff --git a/src/Plotly.NET/Traces/Trace.fs b/src/Plotly.NET/Traces/Trace.fs index 38514bf1f..b9c6c185e 100644 --- a/src/Plotly.NET/Traces/Trace.fs +++ b/src/Plotly.NET/Traces/Trace.fs @@ -101,7 +101,7 @@ type TraceStyle() = static member Line ( [] ?Width: float, - [] ?Color: string, + [] ?Color: Color, [] ?Shape: StyleParam.Shape, [] ?Dash: StyleParam.DrawingStyle, [] ?Smoothing: float, @@ -136,14 +136,14 @@ type TraceStyle() = ( [] ?Size: int, [] ?Opacity: float, - [] ?Color: string, + [] ?Color: Color, [] ?Symbol: StyleParam.Symbol, [] ?MultiSizes: seq<#IConvertible>, [] ?Line: Line, [] ?ColorBar: ColorBar, [] ?Colorscale : StyleParam.Colorscale, - [] ?Colors: seq, - [] ?OutlierColor:string, + //[] ?Colors: seq, + [] ?OutlierColor:Color, [] ?Maxdisplayed: int, [] ?Sizeref: float, [] ?Sizemin: float, @@ -165,7 +165,7 @@ type TraceStyle() = |> Marker.style(?Size=Size,?Color=Color,?Symbol=Symbol, ?Opacity=Opacity,?MultiSizes=MultiSizes,?Line=Line, - ?ColorBar=ColorBar,?Colorscale=Colorscale,?Colors=Colors,?OutlierColor=OutlierColor, + ?ColorBar=ColorBar,?Colorscale=Colorscale,?OutlierColor=OutlierColor, ?Maxdisplayed=Maxdisplayed,?Sizeref=Sizeref,?Sizemin=Sizemin, ?Sizemode=Sizemode,?Cauto=Cauto,?Cmax=Cmax,?Cmin=Cmin,?Cmid=Cmid, ?Autocolorscale=Autocolorscale,?Reversescale=Reversescale,?Showscale=Showscale diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index d3f965dfd..c9debf338 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -234,7 +234,7 @@ type Trace2DStyle() = [] ?ClipOnAxis : bool, [] ?ConnectGaps : bool, [] ?Fill : StyleParam.Fill, - [] ?FillColor : string, + [] ?FillColor : Color, [] ?HoverLabel : Hoverlabel, [] ?HoverOn : StyleParam.HoverOn, [] ?StackGaps : StyleParam.StackGaps, diff --git a/src/Plotly.NET/Traces/TraceDomain.fs b/src/Plotly.NET/Traces/TraceDomain.fs index 465c82b2d..1cf77b3d7 100644 --- a/src/Plotly.NET/Traces/TraceDomain.fs +++ b/src/Plotly.NET/Traces/TraceDomain.fs @@ -259,7 +259,7 @@ type TraceDomainStyle() = [] ?Dimensions : seq, [] ?Line , [] ?Domain , - [] ?Color : seq<#IConvertible>, + [] ?Color : Color, [] ?Labelfont , [] ?Tickfont : Font, [] ?Rangefont : Font diff --git a/tests/Plotly.NET.Tests.FSharpConsole/Program.fs b/tests/Plotly.NET.Tests.FSharpConsole/Program.fs index dc61d7043..bdd44f062 100644 --- a/tests/Plotly.NET.Tests.FSharpConsole/Program.fs +++ b/tests/Plotly.NET.Tests.FSharpConsole/Program.fs @@ -23,7 +23,7 @@ let main argv = |> Chart.withYAxisStyle("my y-axis", Id=StyleParam.SubPlotId.Scene 1) |> Chart.withZAxisStyle("my z-axis") |> Chart.withMarker(Marker.init(Size=5)) - |> Chart.withLine(Line.init(Color="red")) + |> Chart.withLine(Line.init(Color=Color.fromString "red")) |> Chart.withSize(800,800) let rec printObj (d:DynamicObj) = diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/CategoricalCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/CategoricalCharts.fs index e450de841..4a9bf9acd 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/CategoricalCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/CategoricalCharts.fs @@ -18,7 +18,7 @@ let parallelCategoriesChart = Chart.ParallelCategories( dims, - Color=[0.;1.;0.;1.;0.;0.;0.], + Color=Color.fromColorScaleValues [0.;1.;0.;1.;0.;0.;0.], Colorscale = StyleParam.Colorscale.Blackbody ) @@ -43,7 +43,7 @@ let parcoords1Chart = "C",[2.;4.;3.1;5.] "D",[4.;2.;2.;4.;] ] - Chart.ParallelCoord(data,Color="blue") + Chart.ParallelCoord(data,Color=Color.fromString "blue") let parcoordsChart = let v = [| @@ -61,7 +61,7 @@ let parcoordsChart = let dyn = Trace("parcoords") dyn?dimensions <- v - dyn?line <- Line.init(Color = "blue") + dyn?line <- Line.init(Color =Color.fromString "blue") dyn |> GenericChart.ofTraceObject @@ -88,11 +88,11 @@ let ``Parallel coordinates charts`` = let sankey1 = // create nodes - let n1 = Node.Create("a",color="Black") - let n2 = Node.Create("b",color="Red") - let n3 = Node.Create("c",color="Purple") - let n4 = Node.Create("d",color="Green") - let n5 = Node.Create("e",color="Orange") + let n1 = Node.Create("a",color=Color.fromString "Black") + let n2 = Node.Create("b",color=Color.fromString "Red") + let n3 = Node.Create("c",color=Color.fromString "Purple") + let n4 = Node.Create("d",color=Color.fromString "Green") + let n5 = Node.Create("e",color=Color.fromString "Orange") // create links between nodes let link1 = Link.Create(n1,n2,value=1.0) diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs index f07bfa4f4..801dfcdce 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs @@ -187,8 +187,8 @@ let ``Multicharts and subplots`` = let shapesChart = let x = [1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ] let y' = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] - let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3") - let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor="#d3d3d3") + let s1 = Shape.init (StyleParam.ShapeType.Rectangle,2.,4.,3.,4.,Opacity=0.3,Fillcolor=Color.fromHex "#d3d3d3") + let s2 = Shape.init (StyleParam.ShapeType.Rectangle,5.,7.,3.,4.,Opacity=0.3,Fillcolor=Color.fromHex "#d3d3d3") Chart.Line(x,y',Name="line") |> Chart.withShapes([s1;s2]) @@ -201,7 +201,7 @@ let ``Shapes`` = |> chartGeneratedContains shapesChart ); testCase "Layout" ( fun () -> - "var layout = {\"shapes\":[{\"type\":\"rect\",\"x0\":2.0,\"x1\":4.0,\"y0\":3.0,\"y1\":4.0,\"opacity\":0.3,\"fillcolor\":\"#d3d3d3\"},{\"type\":\"rect\",\"x0\":5.0,\"x1\":7.0,\"y0\":3.0,\"y1\":4.0,\"opacity\":0.3,\"fillcolor\":\"#d3d3d3\"}]};" + "var layout = {\"shapes\":[{\"type\":\"rect\",\"x0\":2.0,\"x1\":4.0,\"y0\":3.0,\"y1\":4.0,\"opacity\":0.3,\"fillcolor\":\"rgba(211, 211, 211, 1.0)\"},{\"type\":\"rect\",\"x0\":5.0,\"x1\":7.0,\"y0\":3.0,\"y1\":4.0,\"opacity\":0.3,\"fillcolor\":\"rgba(211, 211, 211, 1.0)\"}]};" |> chartGeneratedContains shapesChart ); ] diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs index f0893ffcc..7f19ec381 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs @@ -250,7 +250,7 @@ let scatterplotMatrixChart = "C",[|2.;4.;3.1;5.|] "D",[|4.;2.;2.;4.;|] ] - Chart.Splom(data, Color="blue") + Chart.Splom(data, Color=Color.fromString "blue") [] let ``Scatterplot matrix charts`` = diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/FinanceCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/FinanceCharts.fs index 1502a6c33..4ded81deb 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/FinanceCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/FinanceCharts.fs @@ -58,13 +58,13 @@ let funnelChart = let x = [|1200.; 909.4; 600.6; 300.; 80.|] // Customize the connector lines used to connect the funnel bars - let connectorLine = Line.init (Color="royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.) + let connectorLine = Line.init (Color=Color.fromString "royalblue", Dash=StyleParam.DrawingStyle.Dot, Width=3.) let connector = FunnelConnector.init(Line=connectorLine) // Customize the outline of the funnel bars - let line = Line.init(Width=2.,Color="3E4E88") + let line = Line.init(Width=2.,Color=Color.fromString "3E4E88") - Chart.Funnel (x,y,Color="59D4E8", Line=line, Connector=connector) + Chart.Funnel (x,y,Color=Color.fromString "59D4E8", Line=line, Connector=connector) |> Chart.withMarginSize(Left=100) [] @@ -85,7 +85,7 @@ let ``Funnel charts`` = let funnelArea = let values = [|5; 4; 3; 2; 1|] let text = [|"The 1st"; "The 2nd"; "The 3rd"; "The 4th"; "The 5th"|] - let line = Line.init (Color="purple", Width=3.) + let line = Line.init (Color=Color.fromString "purple", Width=3.) Chart.FunnelArea(Values=values, Text=text, Line=line) [] diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/GeoMapCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/GeoMapCharts.fs index b98771a34..fbfb072bb 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/GeoMapCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/GeoMapCharts.fs @@ -19,15 +19,15 @@ let moreFeaturesBasemapChart = Geo.init( Resolution=StyleParam.GeoResolution.R50, ShowCoastLines=true, - CoastLineColor="RebeccaPurple", + CoastLineColor=Color.fromString "RebeccaPurple", ShowLand=true, - LandColor="LightGreen", + LandColor=Color.fromString "LightGreen", ShowOcean=true, - OceanColor="LightBlue", + OceanColor=Color.fromString "LightBlue", ShowLakes=true, - LakeColor="Blue", + LakeColor=Color.fromString "Blue", ShowRivers=true, - RiverColor="Blue" + RiverColor=Color.fromString "Blue" ) Chart.PointGeo([]) |> Chart.withGeo myGeo @@ -39,7 +39,7 @@ let cultureMapChart = Visible=false, Resolution=StyleParam.GeoResolution.R50, ShowCountries=true, - CountryColor="RebeccaPurple" + CountryColor=Color.fromString "RebeccaPurple" ) Chart.PointGeo([]) |> Chart.withGeo countryGeo @@ -98,7 +98,7 @@ let pointGeoChart = |> Chart.withGeoStyle( Scope=StyleParam.GeoScope.NorthAmerica, Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea), - CountryColor = "lightgrey" + CountryColor = Color.fromString "lightgrey" ) |> Chart.withMarginSize(0, 0, 0, 0) @@ -135,7 +135,7 @@ let flightsMapChart = Chart.LineGeo( [startCoords; endCoords], Opacity = opacityVals.[i], - Color = "red" + Color = Color.fromString "red" ) ) |> Chart.combine @@ -144,7 +144,7 @@ let flightsMapChart = Scope=StyleParam.GeoScope.NorthAmerica, Projection=GeoProjection.init(StyleParam.GeoProjectionType.AzimuthalEqualArea), ShowLand=true, - LandColor = "lightgrey" + LandColor = Color.fromString "lightgrey" ) |> Chart.withMarginSize(0,0,50,0) |> Chart.withTitle "Feb. 2011 American Airline flights" @@ -238,7 +238,7 @@ let choroplethMap2Chart = Projection=GeoProjection.init(projectionType=StyleParam.GeoProjectionType.Mollweide), ShowLakes=true, ShowOcean=true, - OceanColor="lightblue", + OceanColor= Color.fromString "lightblue", ShowRivers=true) |> Chart.withColorBarStyle ( Title.init(Text="Alcohol consumption[l/y]") diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs index f22decef7..48c7c8e28 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs @@ -88,7 +88,7 @@ let flightsChart = Chart.LineMapbox( [startCoords; endCoords], Opacity = opacityVals.[i], - Color = "red" + Color = Color.fromString "red" ) ) |> Chart.combine diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/PolarCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/PolarCharts.fs index 3388b38e5..853d3c258 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/PolarCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/PolarCharts.fs @@ -19,7 +19,7 @@ let pointPolar = Chart.PointPolar(radial,theta) let linePolar = Chart.LinePolar(radial,theta) - |> Chart.withLineStyle(Color="purple",Dash=StyleParam.DrawingStyle.DashDot) + |> Chart.withLineStyle(Color=Color.fromString "purple",Dash=StyleParam.DrawingStyle.DashDot) let splinePolar = Chart.SplinePolar( diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs index 58c568229..f6faf62d3 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs @@ -196,8 +196,8 @@ let rangePlotsChart = Chart.Range( x,y,yUpper,yLower, StyleParam.Mode.Lines_Markers, - Color="grey", - RangeColor="lightblue") + Color=Color.fromString "grey", + RangeColor=Color.fromString "lightblue") [] let ``Range plot`` = @@ -304,9 +304,9 @@ let tableStyledChart = AlignCells = [HorizontalAlign.Left; HorizontalAlign.Center; HorizontalAlign.Right], ColorHeader = "#45546a", ColorCells = ["#deebf7"; "lightgrey"; "#deebf7"; "lightgrey"], - FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color="white"), + FontHeader = Font.init(FontFamily.Courier_New, Size=12., Color=Color.fromString "white"), HeightHeader= 30., - LineHeader = Line.init(2., "black"), + LineHeader = Line.init(2.,Color.fromString "black"), ColumnWidth = [70; 50; 100; 70], ColumnOrder = [1; 2; 3; 4] ) @@ -330,8 +330,8 @@ let tableColorDependentChart = let proportion = (255. * (value - min) / (max - min)) |> int - Colors.fromRgb 255 (255 - proportion) proportion - |> Colors.toWebColor + ARGB.fromRGB 255 (255 - proportion) proportion + |> ARGB.toWebHex //Assign a color to every cell seperately. Matrix must be transposed for correct orientation. let cellcolor = @@ -392,7 +392,7 @@ let sequencePresentationTableChart = |> Seq.map (fun x -> Seq.append x (seq ["white"])) let font = Font.init(FontFamily.Consolas,Size=14.) - let line = Line.init(0.,"white") + let line = Line.init(0., Color.fromString "white") let chartwidth = 50 + 10 * elementsPerRow Chart.Table(