'Blazor ApexCharts Annotations do not show in graph
I am using BlazorApexCharts and trying to add annotations to a line graph. Problem:* The X-Axis annotation does not show. Here is the code for the XAxis: (Note - to assist me with error-checking, I am creating each object as I go, rather than using the more typical initialization syntax.) Debugging indicates the Annotations object is populated correclty - to me, anyway. I used a similar pattern for a Y-Axis annotation, and it worked fine. Would appreciate suggestions on what needs modifying.
SecOptions.Annotations = new(); //SecOptions is object for all options for the graph
{--- code for Y-Axis annotation goes here --}
SecOptions.Annotations.Xaxis = new(); //create list for XAxisAnnotation objects
AnnotationsXAxis X1 = new(); //create new XAxis annotation X1, set its properties
X1.X = 2151; //this is a value on X Axis
X1.BorderWidth = 2;
X1.BorderColor = "#C83ACA";
X1.StrokeDashArray = 5;
X1.Opacity = 0.9d;
X1.Label = new Label { Text = "Current Year", Style = new Style { FontSize = "18px;" } };
SecOptions.Annotations.Xaxis.Add(X1); //Add XAxis Annotation to list
Solution 1:[1]
I finally solved the problem. Because I had declared the X axis as "XAxisType="XAxisType.Category", the position for the X annotation needed to be a string, not an integer. So, changing 'X1.X = 2151;' to 'X1.X = "2151";' is all that was needed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Ogburn |
