WPF 工具包 - 停用图表动画

发布于 2024-09-18 17:44:38 字数 126 浏览 6 评论 0原文

创建新图表并添加系列(例如 ColumnSeries)和数据时,列将呈现为淡入动画类型,并在屏幕上绘制图表后立即出现。

有什么办法可以阻止这个动画的发生吗?或者,是否有办法强制图表在渲染之前完成动画?

保罗

When a new Chart is created and a Series (ColumnSeries for example) is added along with data the columns are rendered as a type of FadeIn animation and appear a split second after the Chart is drawn on screen.

Is there anyway to stop this animation happening? Alternatively, is there anyway of forcing the chart to complete the animations before rendering?

Paul

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

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

发布评论

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

评论(1

冷弦 2024-09-25 17:44:38

我已经在 http://wpf.codeplex.com/SourceControl/list/changesets 下载了最新的源代码

我的想法是,通过更改不同图表系列(图表点、DataPointStyle)的样式来删除动画

charting:PieDataPoint

尝试删除显示数据的动画并采取使用给定键 (x:key="myStyle" -> DataPointStyle="{StaticResource myStyle}")

并删除 Opacity="0" < code>

从您的样式中删除此视觉状态组

<VisualStateGroup x:Name="RevealStates">
    <VisualStateGroup.Transitions>
        <VisualTransition GeneratedDuration="0:0:0.5" />
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Shown">
        <Storyboard>
            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
        </Storyboard>
    </VisualState>
    <VisualState x:Name="Hidden">
        <Storyboard>
            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
        </Storyboard>
    </VisualState>
</VisualStateGroup>

编辑

这是更改后的样式。

<!--  charting:PieDataPoint  -->
<Style TargetType="charting:PieDataPoint">
    <Setter Property="Background" Value="Orange" />
    <Setter Property="BorderBrush" Value="White" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="RatioStringFormat" Value="{}{0:p2}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="charting:PieDataPoint">
                <Grid x:Name="Root" Opacity="0">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Unselected" />
                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Path x:Name="Slice" Data="{TemplateBinding Geometry}" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeMiterLimit="1">
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <ContentControl Content="{TemplateBinding FormattedDependentValue}" />
                                <ContentControl Content="{TemplateBinding FormattedRatio}" />
                            </StackPanel>
                        </ToolTipService.ToolTip>
                    </Path>
                    <Path x:Name="SelectionHighlight" Data="{TemplateBinding GeometrySelection}" Fill="Red" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                    <Path x:Name="MouseOverHighlight" Data="{TemplateBinding GeometryHighlight}" Fill="White" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

在我第一次尝试删除动画后,我想放弃,因为它没有效果。

但后来我用源代码的反射器查看了我,发现了一种它仍然有效的方法。

不幸的是,设置 DataPointStyle 还不够,我认为这是一个错误。

<chartingToolkit:Chart Margin="8">

  <chartingToolkit:Chart.Series>
    <chartingToolkit:BarSeries x:Name="barSeries"
                                Title="Experience"
                                DataPointStyle="{StaticResource myBarStyle}">
    </chartingToolkit:BarSeries>
  </chartingToolkit:Chart.Series>

</chartingToolkit:Chart>

在包含图表的控件的构造函数中,只需执行以下命令。

this.barSeries.RefreshStyles();

希望这有帮助

i have downloaded the latest source code at http://wpf.codeplex.com/SourceControl/list/changesets

my idea is, to remove the animation by changing the style for the different chart series (chart points, DataPointStyle)

example for charting:PieDataPoint

try to remove the animation for the shown data and take your own style with a given key (x:key="myStyle" -> DataPointStyle="{StaticResource myStyle}")

and remove Opacity="0" at <Grid x:Name="Root" Opacity="0">

remove this visual state group from your style

<VisualStateGroup x:Name="RevealStates">
    <VisualStateGroup.Transitions>
        <VisualTransition GeneratedDuration="0:0:0.5" />
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Shown">
        <Storyboard>
            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
        </Storyboard>
    </VisualState>
    <VisualState x:Name="Hidden">
        <Storyboard>
            <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
        </Storyboard>
    </VisualState>
</VisualStateGroup>

EDIT

This is the changed style.

<!--  charting:PieDataPoint  -->
<Style TargetType="charting:PieDataPoint">
    <Setter Property="Background" Value="Orange" />
    <Setter Property="BorderBrush" Value="White" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="RatioStringFormat" Value="{}{0:p2}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="charting:PieDataPoint">
                <Grid x:Name="Root" Opacity="0">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1" />
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Unselected" />
                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Path x:Name="Slice" Data="{TemplateBinding Geometry}" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeMiterLimit="1">
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <ContentControl Content="{TemplateBinding FormattedDependentValue}" />
                                <ContentControl Content="{TemplateBinding FormattedRatio}" />
                            </StackPanel>
                        </ToolTipService.ToolTip>
                    </Path>
                    <Path x:Name="SelectionHighlight" Data="{TemplateBinding GeometrySelection}" Fill="Red" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                    <Path x:Name="MouseOverHighlight" Data="{TemplateBinding GeometryHighlight}" Fill="White" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

After my first attempt to remove the animation, I wanted to give up, because it has not worked.

But then I looked upon me with the reflector to the source code and have found a way that it still works.

Setting the DataPointStyle unfortunately is not enough, I think it's a bug.

<chartingToolkit:Chart Margin="8">

  <chartingToolkit:Chart.Series>
    <chartingToolkit:BarSeries x:Name="barSeries"
                                Title="Experience"
                                DataPointStyle="{StaticResource myBarStyle}">
    </chartingToolkit:BarSeries>
  </chartingToolkit:Chart.Series>

</chartingToolkit:Chart>

In the constructor of the control where the chart is included simply execute the following.

this.barSeries.RefreshStyles();

hope this helps

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