带渐变的 Silverlight 线图

发布于 2024-09-05 03:15:43 字数 563 浏览 4 评论 0原文

我有一系列的点,我将把它们变成图表上的一条线。我想要的是给图表下方的区域进行渐变填充。它看起来有点类似于这样的彭博图表;

Example Graph

我的问题实际上分为三个部分;

  • 首先,我应该如何只填充图表下方的区域?
  • 其次,如何用渐变填充它?
  • 最后,如果我在同一张图表上有多条线,则多条线下的任何区域都应该有灰度渐变填充,您将如何设置?

我最大的问题是决定使用的数据结构,我可以使用许多多边形状(每条线/数据系列一个),然后告诉画笔进行绘制;

  • 如果它不是任何形状,则为透明 如果
  • 它是一种形状,则一个系列的颜色(相对于高度的 Alpha 给出梯度)
  • 如果它是多个形状,则为黑色(相对于高度的 Alpha 给出梯度)

然后我会绘制形状的边界之后变成白色。

谢谢,

加夫

I have a series of points which I will turn into a line on a graph. What I want is to give the area under the graph a gradient fill. It would look somewhat similar to a Bloomberg graph like this;

Example Graph

My question really has three parts;

  • First, how should I fill only the area under the graph?
  • Second, how do I fill that with a gradient?
  • Finally, if I have multiple lines on the same graph any area under more than one line should have a greyscale gradient fill, how would you set this up?

My biggest problem is deciding on the data structures to use, I could use many multiple sided shapes (One for each line/ data series) and then tell the brush to draw;

  • Transparent if it's not in any shape
  • The colour of one series if it's in one shape (Alpha relative to height to give grad)
  • Black if it's in multiple shapes (Alpha relative to height to give grad)

Then I'd draw the shapes' boundaries in white afterwards.

Thanks,

Gav

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

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

发布评论

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

评论(1

假面具 2024-09-12 03:15:43

使用免费版本的 Visiblox Silverlight 图表 可以实现渐变效果。请参阅示例应用程序“Hindsight”,了解如何将 Visiblox 图表应用于此上下文的应用程序。

我附上了关于如何实现此效果的 XAML 粗略代码片段:

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:v="clr-namespace:Visiblox.Charts;assembly=Visiblox.Charts">

<UserControl.Resources>
    <LinearGradientBrush x:Key="GradientBrush" StartPoint="1.0, 0.0" EndPoint="1.0, 1.0">
        <GradientStop Color="AliceBlue" Offset="0.3" />
        <GradientStop Color="DarkBlue" Offset="0.7" />
    </LinearGradientBrush>
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="White">
    <v:Chart x:Name="Chart">
        <v:Chart.Series>
            <v:LineSeries x:Name="Series" ShowArea="True" AreaFill="{StaticResource GradientBrush}"/>
        </v:Chart.Series>
    </v:Chart>
</Grid>

就我个人而言,我会采取事后诸葛亮的做法,当绘图区域上有多个系列时,删除线条下的区域。我认为此时梯度会妨碍数据,正如您上面提到的,对此采取一些措施会产生计算成本。这也可能导致对数据的误解,因此要小心。

在将数据获取到图表方面,您可以使用 Visiblox BindableDataSeries 将业务对象直接绑定到图表上。 :)

披露:我之前曾担任 Visiblox Charts 的开发人员。

希望这有帮助!

The gradient effect is possible using the free version of Visiblox Silverlight Charts. See the example application 'Hindsight' to see how Visiblox charts can be applied to an application of this context.

I've attached a crude code snippet of the XAML on how to achieve this effect:

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:v="clr-namespace:Visiblox.Charts;assembly=Visiblox.Charts">

<UserControl.Resources>
    <LinearGradientBrush x:Key="GradientBrush" StartPoint="1.0, 0.0" EndPoint="1.0, 1.0">
        <GradientStop Color="AliceBlue" Offset="0.3" />
        <GradientStop Color="DarkBlue" Offset="0.7" />
    </LinearGradientBrush>
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="White">
    <v:Chart x:Name="Chart">
        <v:Chart.Series>
            <v:LineSeries x:Name="Series" ShowArea="True" AreaFill="{StaticResource GradientBrush}"/>
        </v:Chart.Series>
    </v:Chart>
</Grid>

Personally, I would take the action that Hindsight does, removing the area under lines when there are multiple series on the plot area. I think at that point the gradients get in the way of the data, and as you mentioned above, to do something about this incurs a computational cost. This could also lead to misinterpretations of the data so be wary.

In terms of getting your data to the chart, you can use the Visiblox BindableDataSeries to bind your business objects directly onto the chart. :)

Disclosure: I have previously worked as a developer on Visiblox Charts.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文