Annotation not showing in C#
karlipl opened this issue · 2 comments
karlipl commented
Hello,
i try to add a simple annotation to my chart in C# and it is not showing up. I see the annotation arrow at x=5, y=5 (which is the wrong position) and no text.
I am using the latest nuget version 4.2.0.
This is my simple example code:
Annotation annotation = new Annotation();
annotation.SetValue("X", 3.0f);
annotation.SetValue("Y", 4.0f);
annotation.SetValue("Text", "Test");
var chart = Chart.Point<int, int, string>(x: Enumerable.Range(0, 11), y: Enumerable.Range(0, 11))
.WithAnnotation(annotation);
Could somebody help me what my issue is? I guess it is a minor thing, but i am unable to see it.
Regards
kMutagene commented
Hey @karlipl you are using the advanced, low level dynamic obj API. To successfully use it, you have to know how the attributes are called in actual plotly JSON. Try lowercase names (e.g. "x" and "text") and it should work. Alternatively, use Annotation.init which handles these things
karlipl commented
OMG, i knew it was something stupid. Works now. Thanks for the help