@@ -48,14 +48,6 @@ module HTML =
48
48
</html>"""
49
49
50
50
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>"""
59
51
let chart =
60
52
let newScript = new System.Text.StringBuilder()
61
53
newScript.AppendLine( """ <div id="[ID]"><!-- Plotly chart will be drawn inside this DIV --></div>""" ) |> ignore
@@ -99,14 +91,13 @@ module HTML =
99
91
newScript.ToString()
100
92
101
93
102
- let staticChart =
94
+ let imageChart =
103
95
""" <div id="[ID]" style="display: none;"><!-- Plotly chart will be drawn inside this DIV --></div>
104
96
105
- <img id="jpg-export "></img>
97
+ <img id="chart-image "></img>
106
98
107
99
<script>
108
- var d3 = Plotly.d3;
109
- var img_jpg= d3.select('#jpg-export');
100
+ var img_jpg = d3.select('#chart-image');
110
101
var data = [DATA];
111
102
var layout = [LAYOUT];
112
103
var config = [CONFIG];
@@ -388,12 +379,6 @@ module GenericChart =
388
379
.Replace( " [CONFIG]" , configJson)
389
380
|> DisplayOptions.replaceHtmlPlaceholders displayOpts
390
381
391
-
392
-
393
-
394
-
395
-
396
-
397
382
/// Converts a GenericChart to it HTML representation and set the size of the div
398
383
let toChartHtmlWithSize ( width : int ) ( height : int ) ( gChart : GenericChart ) =
399
384
let guid = Guid.NewGuid() .ToString()
@@ -412,7 +397,6 @@ module GenericChart =
412
397
413
398
let displayOpts = getDisplayOptions gChart
414
399
415
-
416
400
HTML
417
401
.chart
418
402
.Replace( " [ID]" , guid)
@@ -431,8 +415,16 @@ module GenericChart =
431
415
432
416
HTML.doc.Replace( " [CHART]" , chartMarkup) |> DisplayOptions.replaceHtmlPlaceholders displayOpts
433
417
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" ) >]
434
419
/// 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/
435
426
let toChartImage ( format : StyleParam.ImageFormat ) gChart =
427
+
436
428
let guid = Guid.NewGuid() .ToString()
437
429
438
430
let tracesJson =
@@ -443,30 +435,32 @@ module GenericChart =
443
435
let layout = getLayout gChart
444
436
JsonConvert.SerializeObject( layout, jsonConfig)
445
437
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
456
450
457
- html
458
451
459
452
/// Converts a GenericChart to an image and embeds it into a html page
460
453
let toEmbeddedImage ( format : StyleParam.ImageFormat ) gChart =
461
- let html =
462
- let chartMarkup = toChartImage format gChart
463
454
464
- HTML
465
- .doc
466
- .Replace( " [CHART]" , chartMarkup)
467
- .Replace( " [CONFIG]" , " {}" )
455
+ let chartMarkup = toChartImage format gChart
456
+
457
+ let displayOpts = getDisplayOptions gChart
468
458
469
- html
459
+ HTML
460
+ .doc
461
+ .Replace( " [CHART]" , chartMarkup)
462
+ .Replace( " [CONFIG]" , " {}" )
463
+ |> DisplayOptions.replaceHtmlPlaceholders displayOpts
470
464
471
465
472
466
/// 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