WPF BubbleSeries,迭代气泡并设置样式

发布于 2024-10-02 22:25:23 字数 264 浏览 0 评论 0原文

我在图表中有一个 BubbleSeries。我将数据绑定到 BubbleSeries 并为气泡设置特定的颜色。

我想要做的是迭代所有气泡,并根据值将每个气泡的颜色设置为特定颜色。

我的泡泡,两个系列: alt text

灰色气泡应始终为灰色,但蓝色气泡应根据其 SizeValue 具有不同的颜色。

有任何线索如何迭代气泡并设置其特定颜色吗?可能的?

I have a BubbleSeries within a Chart. I bind data to the BubbleSeries and set a specific color to the bubbles.

What I want to do is to iterate over all the bubbles and set each bubble's color to specific color depending on the value.

My bubbles, two series:
alt text

The gray bubbles should always be gray, but the blue bubbles should have different colors depending on their SizeValue.

Any clues how to iterate over the bubbles and set their specific color? Possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦纸 2024-10-09 22:25:23

我实际上找到了一个解决方案:

我不需要迭代我的气泡,而是使用 ValueConverter 解决了问题。

我有一个 ValueConverter,它接受一个值并根据该值返回一个颜色。

我将 ValueConverter 的响应绑定到 DataPointStyle:

        <Charting:BubbleSeries.DataPointStyle>
                    <Style
                        TargetType="Charting:BubbleDataPoint">
                        <Setter
                            Property="Background">
                            <Setter.Value>
                                <SolidColorBrush
                                    Color="{Binding Path=PropertyOnObjectBoundToGraph, Converter={StaticResource colorFormater}}"></SolidColorBrush>
                            </Setter.Value>
                        </Setter>

I actually found a solution:

I didn't need to iterate over my bubbles, instead I solved the problem with a ValueConverter.

I have a ValueConverter that takes a value and return a color depending on that value.

I bind the response from my ValueConverter to my DataPointStyle:

        <Charting:BubbleSeries.DataPointStyle>
                    <Style
                        TargetType="Charting:BubbleDataPoint">
                        <Setter
                            Property="Background">
                            <Setter.Value>
                                <SolidColorBrush
                                    Color="{Binding Path=PropertyOnObjectBoundToGraph, Converter={StaticResource colorFormater}}"></SolidColorBrush>
                            </Setter.Value>
                        </Setter>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文