@@ -48,14 +48,6 @@ module HTML =
4848</html>"""
4949
5050
51- // let chart =
52- // """<div id="[ID]" style="width: [WIDTH]px; height: [HEIGHT]px;"><!-- Plotly chart will be drawn inside this DIV --></div>
53- //<script>
54- // var data = [DATA];
55- // var layout = [LAYOUT];
56- // var config = [CONFIG];
57- // Plotly.newPlot('[ID]', data, layout, config);
58- //</script>"""
5951 let chart =
6052 let newScript = new System.Text.StringBuilder()
6153 newScript.AppendLine( """ <div id="[ID]"><!-- Plotly chart will be drawn inside this DIV --></div>""" ) |> ignore
@@ -99,14 +91,13 @@ module HTML =
9991 newScript.ToString()
10092
10193
102- let staticChart =
94+ let imageChart =
10395 """ <div id="[ID]" style="display: none;"><!-- Plotly chart will be drawn inside this DIV --></div>
10496
105- <img id="jpg-export "></img>
97+ <img id="chart-image "></img>
10698
10799 <script>
108- var d3 = Plotly.d3;
109- var img_jpg= d3.select('#jpg-export');
100+ var img_jpg = d3.select('#chart-image');
110101 var data = [DATA];
111102 var layout = [LAYOUT];
112103 var config = [CONFIG];
@@ -388,12 +379,6 @@ module GenericChart =
388379 .Replace( " [CONFIG]" , configJson)
389380 |> DisplayOptions.replaceHtmlPlaceholders displayOpts
390381
391-
392-
393-
394-
395-
396-
397382 /// Converts a GenericChart to it HTML representation and set the size of the div
398383 let toChartHtmlWithSize ( width : int ) ( height : int ) ( gChart : GenericChart ) =
399384 let guid = Guid.NewGuid() .ToString()
@@ -412,7 +397,6 @@ module GenericChart =
412397
413398 let displayOpts = getDisplayOptions gChart
414399
415-
416400 HTML
417401 .chart
418402 .Replace( " [ID]" , guid)
@@ -431,8 +415,16 @@ module GenericChart =
431415
432416 HTML.doc.Replace( " [CHART]" , chartMarkup) |> DisplayOptions.replaceHtmlPlaceholders displayOpts
433417
418+ [<Obsolete( " This function will be dropped in the 2.0 release. Create either a static chart (e.g using Config.init(StaticPlot=true)) or use Plotly.NET.ImageExport" ) >]
434419 /// Converts a GenericChart to its Image representation
420+ ///
421+ /// This function is obsolete and will soon be dropped.
422+ ///
423+ /// Either use a static plot config (e.g. myChart |> Chart.withConfig(Config.init(StaticPlot=true)) https://plotly.net/00_3_chart-config.html#Static-plots
424+ ///
425+ /// or use the Plotly.NET.ImageExport package https://www.nuget.org/packages/Plotly.NET.ImageExport/
435426 let toChartImage ( format : StyleParam.ImageFormat ) gChart =
427+
436428 let guid = Guid.NewGuid() .ToString()
437429
438430 let tracesJson =
@@ -443,30 +435,32 @@ module GenericChart =
443435 let layout = getLayout gChart
444436 JsonConvert.SerializeObject( layout, jsonConfig)
445437
446- let html =
447- HTML
448- .staticChart
449- .Replace( " [WIDTH]" , string 600 )
450- .Replace( " [HEIGHT]" , string 600 )
451- .Replace( " [ID]" , guid)
452- .Replace( " [DATA]" , tracesJson)
453- .Replace( " [LAYOUT]" , layoutJson)
454- .Replace( " [IMAGEFORMAT]" , format.ToString() .ToLower())
455- .Replace( " [CONFIG]" , " {}" )
438+ let displayOpts = getDisplayOptions gChart
439+
440+ HTML
441+ .imageChart
442+ .Replace( " [WIDTH]" , string 600 )
443+ .Replace( " [HEIGHT]" , string 600 )
444+ .Replace( " [ID]" , guid)
445+ .Replace( " [DATA]" , tracesJson)
446+ .Replace( " [LAYOUT]" , layoutJson)
447+ .Replace( " [IMAGEFORMAT]" , format.ToString() .ToLower())
448+ .Replace( " [CONFIG]" , " {}" )
449+ |> DisplayOptions.replaceHtmlPlaceholders displayOpts
456450
457- html
458451
459452 /// Converts a GenericChart to an image and embeds it into a html page
460453 let toEmbeddedImage ( format : StyleParam.ImageFormat ) gChart =
461- let html =
462- let chartMarkup = toChartImage format gChart
463454
464- HTML
465- .doc
466- .Replace( " [CHART]" , chartMarkup)
467- .Replace( " [CONFIG]" , " {}" )
455+ let chartMarkup = toChartImage format gChart
456+
457+ let displayOpts = getDisplayOptions gChart
468458
469- html
459+ HTML
460+ .doc
461+ .Replace( " [CHART]" , chartMarkup)
462+ .Replace( " [CONFIG]" , " {}" )
463+ |> DisplayOptions.replaceHtmlPlaceholders displayOpts
470464
471465
472466 /// Creates a new GenericChart whose traces are the results of applying the given function to each of the trace of the GenericChart.
0 commit comments