首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Livecharts中的视觉元素?

Livecharts中的视觉元素?
EN

Stack Overflow用户
提问于 2019-05-03 03:26:44
回答 1查看 796关注 0票数 0

我想在5秒的时间内将一条垂直线从笛卡尔图表的开头移动到结尾。我尝试查看网站https://lvcharts.net/App/examples/v1/wpf/Visual%20Elements中提供的示例,但图形中的UI元素与代码不匹配。

当我尝试将这条线直接添加到图表中时,这条线工作正常,但图表不显示。

代码语言:javascript
复制
<lvc:CartesianChart Name="CartChart" Height="150" Zoom="Xy" Pan="Xy">

    <lvc:CartesianChart.Series>
        <lvc:LineSeries Values="{Binding audioPoints}" StrokeThickness="1" PointGeometry="{x:Null}" Visibility="Visible" />
    </lvc:CartesianChart.Series>

    <Line x:Name="anotherLine" Stroke="Black" Height="160" X1="0"X2="0" Y1="0" Y2="160"/>

</lvc:CartesianChart>
EN

回答 1

Stack Overflow用户

发布于 2020-01-31 05:33:08

我找到了这个代码示例,我认为它将演示您需要做的事情。您应该能够将其中的大部分内容转换为数据绑定和xaml。

需要注意的是,您向CartesianChart上的VisualElements集合添加了一个VisualElement。将VisualElement对象的UIElement属性设置为要添加到图表中的WPF控件。

https://lvcharts.net/App/examples/v1/wf/Visual%20Elements

代码语言:javascript
复制
    cartesianChart1.VisualElements.Add(new VisualElement
    {
        X = 0.5,
        Y = 7,
        HorizontalAlignment = HorizontalAlignment.Center,
        VerticalAlignment = VerticalAlignment.Top,
        UIElement = new TextBlock //notice this property must be a wpf control
        {
            Text = "Warning!",
            FontWeight = FontWeights.Bold,
            FontSize = 16,
            Opacity = 0.6
        }
    });

    cartesianChart1.VisualElements.Add(new VisualElement()
    {
            X=0,
            Y=myCalculatedValue,
            UIElement = new Rectangle()
            {
                Width= width,
                Margin= new Thickness(-seriesWidth/2, 0, 0, 0),
                Height=6,
                Fill=Brushes.Black,
                VerticalAlignment = VerticalAlignment.Top
            }
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55959024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档