增加WPF Chartingtoolkit的图表大小

时间:2018-03-04 19:02:11

标签: c# wpf xaml charts toolkit

我目前正在开发一个小项目,在那里我使用了WPF Charting Toolkit。

now im a bit annoyed by these huge margin

<ch:Chart Grid.Row="1" x:Name="Chart">
        <ch:Chart.LegendStyle>
            <Style TargetType="{x:Type vt:Legend}">
                <Setter Property="Width" Value="0"/>
                <Setter Property="Height" Value="0"/>
            </Style>
        </ch:Chart.LegendStyle>
        <ch:LineSeries ItemsSource="{Binding WeightChartData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DependentValuePath="Value" IndependentValuePath="Key" />
            <ch:Chart.Axes>
            <ch:LinearAxis Minimum="{Binding MinVal}" Maximum="{Binding MaxVal}" Orientation="Y"/>
        </ch:Chart.Axes>
    </ch:Chart>

这是图表中的XAML。

有什么方法可以让图表更大

1 个答案:

答案 0 :(得分:0)

为了使边距更舒适,您必须为图表创建新样式。最简单的方法是完全复制原始图表样式并对其进行修改以满足您的需求。

original style is available from GitHub。从该文件中,您可以找到Style TargetType =“charting:Chart”,其中定义了大边距。例如:

<Setter Property="LegendStyle">
            <Setter.Value>
                <Style TargetType="datavis:Legend">
                    <Setter Property="Margin" Value="15,0,15,0" />

或者,您可以查看以下SO帖子中的“最低限度”图表样式,并根据您的需要进行修改:Change margin around plot area and title in WPF Toolkit chart