@@ -94,8 +94,8 @@ module GenericChart =
94
94
let tryGetLayoutSize gChart =
95
95
let layout = getLayout gChart
96
96
let width , height =
97
- ReflectionHelper.tryGetPropertyValueAs < float> layout " width" ,
98
- ReflectionHelper.tryGetPropertyValueAs < float> layout " height"
97
+ layout.TryGetTypedValue < float> " width" ,
98
+ layout.TryGetTypedValue < float> " height"
99
99
match ( width, height) with
100
100
|( Some w, Some h) -> Some ( w, h)
101
101
|_ -> None
@@ -141,7 +141,7 @@ module GenericChart =
141
141
142
142
143
143
144
- /// Converts a GenericChart to it HTML representation
144
+ /// Converts a GenericChart to it HTML representation. The div layer has a default size of 600 if not specified otherwise.
145
145
let toChartHTML gChart =
146
146
let guid = Guid.NewGuid() .ToString()
147
147
let tracesJson =
@@ -150,12 +150,18 @@ module GenericChart =
150
150
let layoutJson =
151
151
getLayout gChart
152
152
|> JsonConvert.SerializeObject
153
+
154
+ let dims = tryGetLayoutSize gChart
155
+ let width , height =
156
+ match dims with
157
+ | Some ( w, h) -> w, h
158
+ | None -> 600. , 600.
153
159
154
160
let html =
155
161
HTML.chart
156
162
//.Replace("style=\"width: [WIDTH]px; height: [HEIGHT]px;\"","style=\"width: 600px; height: 600px;\"")
157
- .Replace( " [WIDTH]" , string 600 )
158
- .Replace( " [HEIGHT]" , string 600 )
163
+ .Replace( " [WIDTH]" , string width )
164
+ .Replace( " [HEIGHT]" , string height )
159
165
.Replace( " [ID]" , guid)
160
166
.Replace( " [DATA]" , tracesJson)
161
167
.Replace( " [LAYOUT]" , layoutJson)
0 commit comments