如何使用 LiveCharts 更改 DataLabels 颜色
How to change DataLabels color by using LiveCharts
我正在为折线图和柱状图使用实时图表。
我启用了数据标签功能。
但我使用深色作为背景。它使数据标签看起来很模糊。
我找不到可以更改数据标签颜色的位置。任何人都知道如何改变它?
在 C# 中
ProductionAndTargetCollection = new SeriesCollection
{
new LineSeries
{
Title = "Target",
Values = DailyTargetValue,
DataLabels = true,
LineSmoothness = 0
},
new ColumnSeries
{
Title = "Production",
DataLabels = true,
Values = DailyProductionValue
}
};
在 WPF 中
<lvc:CartesianChart Name="MidRightChart" Series="{Binding ProductionAndTargetCollection}" DisableAnimations="True">
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelsRotation="0" Labels="{Binding ProductionAndTargetLabels}" Foreground="White" Position="LeftBottom">
<lvc:Axis.Separator >
<lvc:Separator Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="White" MinValue="0"/>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
您应该设置 Series
的 Foreground
属性 以更改数据标签的颜色:
new ColumnSeries
{
Title = "Production",
DataLabels = true,
Values = DailyProductionValue,
Foreground = Brushes.Red // <--
}
我正在为折线图和柱状图使用实时图表。
我启用了数据标签功能。
但我使用深色作为背景。它使数据标签看起来很模糊。
我找不到可以更改数据标签颜色的位置。任何人都知道如何改变它?
在 C# 中
ProductionAndTargetCollection = new SeriesCollection
{
new LineSeries
{
Title = "Target",
Values = DailyTargetValue,
DataLabels = true,
LineSmoothness = 0
},
new ColumnSeries
{
Title = "Production",
DataLabels = true,
Values = DailyProductionValue
}
};
在 WPF 中
<lvc:CartesianChart Name="MidRightChart" Series="{Binding ProductionAndTargetCollection}" DisableAnimations="True">
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelsRotation="0" Labels="{Binding ProductionAndTargetLabels}" Foreground="White" Position="LeftBottom">
<lvc:Axis.Separator >
<lvc:Separator Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="White" MinValue="0"/>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
您应该设置 Series
的 Foreground
属性 以更改数据标签的颜色:
new ColumnSeries
{
Title = "Production",
DataLabels = true,
Values = DailyProductionValue,
Foreground = Brushes.Red // <--
}