如何调整 Syncfusion 图表的水平线注释的文本颜色?
How to adjust text color for Horizontal Line Annotation for Syncfusion chart?
我正在我的 Syncfusion 图表上实现一些 HorizontalLineAnnotation 元素,它工作正常。但是,我找不到控制文本大小和颜色的注释属性,以及注释标签的属性。
这些似乎都默认呈现蓝色,我在 XAML 或 C# 中没有获得任何选项来更改这些属性。我看到这些属性可用于其他类型的注释,但 none 用于 HorizontalLineAnnotation。对我遗漏的内容有帮助吗?
谢谢。
XAML 代码:
<chart:HorizontalLineAnnotation Y1="48.92" ShowAxisLabel="True" Text="Yesterday's Close" StrokeColor="yellow" FillColor="red" />
C# 代码
HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation()
{
Y1 = 49.92,
ShowAxisLabel = true,
Text = "Today's Open"
};
chart.ChartAnnotations.Add(horizontalLineAnnotation);
如果您查看 Syncfusion samples, you'll find this
ChartAnnotationLabelStyle horizontalAnnotationLabelStyle = new ChartAnnotationLabelStyle();
horizontalAnnotationLabelStyle.Margin = new Thickness(0, 0, 0, 20);
horizontalAnnotationLabelStyle.VerticalTextAlignment = ChartAnnotationAlignment.Start;
horizontalAnnotationLabelStyle.HorizontalTextAlignment = ChartAnnotationAlignment.End;
horizontalLineAnnotation.LabelStyle = horizontalAnnotationLabelStyle;
并且根据 docs,有 TextColor、BackgroundColor 等属性
谢谢!使用您提供的信息,我使用了以下代码并能够实现我的目标。
HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation()
{
Y1 = (double)quoteData.previousClose,
ShowAxisLabel = true,
Text = "Yesterday's Close",
StrokeColor = Color.FromHex("#55daec0e"),
};
horizontalLineAnnotation.LabelStyle.TextColor = Color.FromHex("#55daec0e");
myChart.ChartAnnotations.Add(horizontalLineAnnotation);
我正在我的 Syncfusion 图表上实现一些 HorizontalLineAnnotation 元素,它工作正常。但是,我找不到控制文本大小和颜色的注释属性,以及注释标签的属性。
这些似乎都默认呈现蓝色,我在 XAML 或 C# 中没有获得任何选项来更改这些属性。我看到这些属性可用于其他类型的注释,但 none 用于 HorizontalLineAnnotation。对我遗漏的内容有帮助吗?
谢谢。
XAML 代码:
<chart:HorizontalLineAnnotation Y1="48.92" ShowAxisLabel="True" Text="Yesterday's Close" StrokeColor="yellow" FillColor="red" />
C# 代码
HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation()
{
Y1 = 49.92,
ShowAxisLabel = true,
Text = "Today's Open"
};
chart.ChartAnnotations.Add(horizontalLineAnnotation);
如果您查看 Syncfusion samples, you'll find this
ChartAnnotationLabelStyle horizontalAnnotationLabelStyle = new ChartAnnotationLabelStyle();
horizontalAnnotationLabelStyle.Margin = new Thickness(0, 0, 0, 20);
horizontalAnnotationLabelStyle.VerticalTextAlignment = ChartAnnotationAlignment.Start;
horizontalAnnotationLabelStyle.HorizontalTextAlignment = ChartAnnotationAlignment.End;
horizontalLineAnnotation.LabelStyle = horizontalAnnotationLabelStyle;
并且根据 docs,有 TextColor、BackgroundColor 等属性
谢谢!使用您提供的信息,我使用了以下代码并能够实现我的目标。
HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation()
{
Y1 = (double)quoteData.previousClose,
ShowAxisLabel = true,
Text = "Yesterday's Close",
StrokeColor = Color.FromHex("#55daec0e"),
};
horizontalLineAnnotation.LabelStyle.TextColor = Color.FromHex("#55daec0e");
myChart.ChartAnnotations.Add(horizontalLineAnnotation);