gpt4 book ai didi

How to change color of selected ChartPoints in LiveCharts2?(如何更改LiveCharts2中选定图表点的颜色?)

转载 作者:bug小助手 更新时间:2023-10-28 11:48:16 24 4
gpt4 key购买 nike



I'm migrating a small WPF app from LiveCharts to LiveCharts2. I would like to change the color of few ChartPoints in the CartesianChartControl based on their values. In the (old) LiveCharts implementation, I created a custom mapper, which returns a new SolidColorBrush for these points (see LiveCharts: Color series with different color).

我正在将一个小型WPF应用程序从LiveCharts迁移到LiveCharts2。我想根据CartesianChartControl中的几个图表点的值更改它们的颜色。在(旧的)LiveCharts实现中,我创建了一个定制映射器,它为这些点返回一个新的SolidColorBrush(请参阅LiveCharts:不同颜色的颜色系列)。


In LiveCharts2 the mapper implementation has been changed. I found a way how to implement own mapper for the values (LiveCharts2 - Overview Mappers), but I'm still looking for a way to change the ChartPoint color. Which property should be used to change the Fill settings of the ISeries instance?

在LiveCharts2中,映射器实现已更改。我找到了一种方法来实现自己的值映射器(LiveCharts2-概述映射器),但我仍然在寻找一种更改ChartPoint颜色的方法。应该使用哪个属性来更改iSeries实例的填充设置?


Any ideas?

有什么主意吗?


更多回答

This changed drastically in v2, I have noticed this confusion on many users, I will consider an example about this feature.

这在v2中发生了很大的变化,我已经注意到许多用户对此感到困惑,我将考虑一个关于此功能的示例。

Do you have some time estimation or how I can proceed?

你有没有一些时间估计,或者我该如何继续?

There is now an axample: livecharts.dev/docs/WPF/2.0.0-beta.950/…

现在有一个AX样例:liveharts.dev/docs/wpf/2.0.0-beta.950/…

Thanks for your support and the fast response. Because I use VB the converted version of your code is posted below. The only one limitation to me is the necessity to use Object in the lambda method. The real object type is CharPoint(Of TModel, TVisual, TLabel). Is it possible to define an interface for all TVisual and TLabel types? This will simplify the access and increase the type checking.

感谢您的支持和快速响应。因为我使用的是VB,所以你的代码的转换版本在下面发布。对我来说唯一的限制是必须在lambda方法中使用Object。真正的对象类型是CharPoint(Of TModel,TVisual,TLabel)。是否可以为所有TVisual和TLabel类型定义一个接口?这将简化访问并增加类型检查。

优秀答案推荐

The LiveCharts2 has a great architecture, making easy the access the visual components. Because I use VB instead of C# you can find here the VB version of the (original C# sample).

LiveCharts2有一个很棒的架构,使得访问可视化组件变得很容易。因为我使用的是VB而不是C#,所以您可以在这里找到VB版本的(原始C#示例)。


Private _TestSerie1 As ColumnSeries(Of Integer) = New ColumnSeries(Of Integer) With {
.Values = New Integer() {2, 5, 4, 6, 8, 3, 2, 4, 6},
.DataLabelsPaint = New SolidColorPaint(New SKColor(30, 30, 30)),
.DataLabelsPosition = DataLabelsPosition.Top,
.WhenPointMeasured = Sub(point As Object)
If point.Visual IsNot Nothing Then
Dim paint As SolidColorPaint = paints(point.Index Mod paints.Length)
point.Visual.Fill = paint
End If
End Sub
}

更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com