Search code examples
c#wpfwpftoolkitdata-visualization

How to modify the width of a column graph?


The motive is simple. Please, see the below image. All the columns are stretched (width). Is there a way to specify a width for each column?

column chart example

    <ChartTools:Chart x:Name="PieCustomerChart" Title="A" Background="LightSteelBlue">

        <ChartTools:Chart.Axes>
            <ChartTools:LinearAxis Orientation="Y" ShowGridLines="True"  Minimum="0" Maximum="1" />
        </ChartTools:Chart.Axes>

        <ChartTools:Chart.Series>
            <ChartTools:ColumnSeries Title="Exam" ItemsSource="{Binding Scores}"
                IndependentValueBinding="{Binding Key}"
                DependentValueBinding="{Binding Value}" IsSelectionEnabled="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            </ChartTools:ColumnSeries>
        </ChartTools:Chart.Series>
    </ChartTools:Chart>

Solution

  • I had a quick look at the source code on codeplex and it looks like you cannot set the column width individually. It is automatically calculated. Your only way for now is to either add that feature yourself or to set the width of the Chart dependent on the number of columns.