【问题标题】:How to change DataLabels color by using LiveCharts如何使用 LiveCharts 更改 DataLabels 颜色
【发布时间】:2020-12-21 22:32:10
【问题描述】:

我正在为折线图和柱形图使用实时图表。 我启用了数据标签功能。 但我使用深色作为背景。它使数据标签看起来很模糊。 我找不到可以更改数据标签颜色的地方。有谁知道怎么改?

在 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>

【问题讨论】:

    标签: c# wpf livecharts


    【解决方案1】:

    你应该设置SeriesForeground属性来改变数据标签的颜色:

    new ColumnSeries
    {
        Title = "Production",
        DataLabels = true,
        Values = DailyProductionValue,
        Foreground = Brushes.Red // <--
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多