1

Im currently working on a little Project, where i make use of the 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>

this is the XAML from the chart.

is there any way i can make the Chart bigger

Community
  • 1
  • 1
Felix Stumvoll
  • 122
  • 4
  • 16

1 Answers1

0

In order to make the margins more comfortable, you have to create a new style for the Chart. Easiest way is to copy the original Chart style completely and modify it to meet your needs.

The original style is available from GitHub. From that file you can find Style TargetType="charting:Chart", where the large margins are defined. For example:

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

Alternatively, you can check the following SO post for a "bare minimum" chart style and to modify it for your needs: Change margin around plot area and title in WPF Toolkit chart

Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63