Skip to content

Commit 90bd8ba

Browse files
committed
wip native interactive formatter
1 parent a3b64e1 commit 90bd8ba

File tree

5 files changed

+147
-25
lines changed

5 files changed

+147
-25
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Plotly.NET.CSharp
8+
{
9+
[AttributeUsage(AttributeTargets.Class)]
10+
internal class TypeFormatterSourceAttribute : Attribute
11+
{
12+
public TypeFormatterSourceAttribute(Type formatterSourceType)
13+
{
14+
FormatterSourceType = formatterSourceType;
15+
}
16+
17+
public Type FormatterSourceType { get; }
18+
19+
public string[] PreferredMimeTypes { get; set; }
20+
}
21+
internal class MyConventionBasedFormatter
22+
{
23+
public string MimeType { get; set; }
24+
25+
public bool Format(object instance, TextWriter writer)
26+
{
27+
if (instance is Plotly.NET.GenericChart myObj)
28+
{
29+
writer.Write($"<div>Custom formattering for {myObj}</div>");
30+
return true;
31+
}
32+
else
33+
{
34+
return false;
35+
}
36+
}
37+
}
38+
internal class MyConventionBasedFormatterSource
39+
{
40+
public IEnumerable<object> CreateTypeFormatters()
41+
{
42+
yield return new MyConventionBasedFormatter { MimeType = "text/html" };
43+
}
44+
}
45+
46+
}

src/Plotly.NET.ImageExport/Playground.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#r "nuget: Deedle"
33
#r "nuget: FSharpAux"
44
#r "nuget: DynamicObj"
5-
#r "nuget: Newtonsoft.Json, 13.0.1"
5+
#r "nuget: Newtonsoft.JSON, 13.0.3"
66

77
#load "../Plotly.NET/InternalUtils.fs"
88

src/Plotly.NET/RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### 5.1.0 - September 04 2024
22

3+
Maintenance release to prevent Plotly.NET breaking for users that upgrade the DynamicObj dependency to >=3.0.0. DynamicObj is now pinned to the version range [2.0.0, 3.0.0) until we manage to make Plotly.NET work with the major changes in that lib.
4+
35
### 5.0.0 - May 27 2024
46

57
Major release with lots of bug fixes, improvements, and upstream feature additions from plotly.js. Many changes are backwards-incompatible with previous versions.

tests/ExtensionLibsTests/InteractiveTests/Formatting.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module ConventionBased =
4242

4343
[<Tests>]
4444
let ``Convention-based Formatting`` =
45-
testList "Convention-based Formatting" [
45+
ptestList "Convention-based Formatting" [
4646
testCase "Convention based formatter sources can provide lazy registration of custom formatters" <| fun _ ->
4747
let o = ConventionBased.TypeWithCustomFormatter()
4848
let formatted = o.ToDisplayString()

0 commit comments

Comments
 (0)