首页 > 解决方案 > 如何调整 Syncfusion 图表的水平线注释的文本颜色?

问题描述

我在我的 Syncfusion 图表上实现了一些 Horizo​​ntalLineAnnotation 元素,它工作正常。但是,我找不到控制文本大小和颜色的注释的属性,以及注释标签的属性。

这些似乎都默认呈现蓝色,我在 XAML 或 C# 中没有任何选项来更改这些属性。我看到这些属性可用于其他类型的注释,但对于 Horizo​​ntalLineAnnotation 则没有。对我所缺少的有任何帮助吗?

谢谢。

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);

在此处输入图像描述

标签: c#xamarinsyncfusion

解决方案


谢谢!使用您提供的信息,我使用了以下代码并且能够实现我的目标。

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);

推荐阅读