ColumnSeries

Apr 20, 2014 at 2:00 PM
Hi,

im trying to use ColumnSeries with OxyPlot.

XAML-Code:
<Window x:Class="ChartTests.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:oxy="http://oxyplot.codeplex.com"
    Title="ChartTests" Height="600" Width="600"
    >
    <Grid>
        <DockPanel>
            <StackPanel
                Orientation="Horizontal"
                DockPanel.Dock="Top">
                <Button
                    Margin="5,5,5,0">
                </Button>
                <Button
                    Margin="5,5,5,0">
                </Button>
                <Button
                    Margin="5,5,5,0">
                </Button>
            </StackPanel>
            <oxy:Plot
                Name="MainChart"
                Title="{Binding ChartTitle}">
                <oxy:Plot.Axes>
                    <oxy:LinearAxis 
                        AbsoluteMinimum="0"
                        AbsoluteMaximum="100"/>
                </oxy:Plot.Axes>
                <oxy:Plot.Series>
                    <oxy:ColumnSeries
                        Title="{Binding SeriesName}"
                        ItemsSource="{Binding Items}">
                    </oxy:ColumnSeries>
                </oxy:Plot.Series>
            </oxy:Plot>
        </DockPanel>
    </Grid>
</Window>
DataContext:
public class MainWindowDataContext
{
    public string ChartTitle { get; set; }
    public List<ColumnItem> Items { get; set; } //From OxyPlot.Series
    public string SeriesName { get; set; }
    public int YAMax { get; set; }
    public int YAMin { get; set; }
        
    public MainWindowDataContext()
    {
         InitializeData();
    }
        
     private void InitializeData()
     {
         ChartTitle = "Main Chart";
            
        SeriesName = "Mitarbeiter";
            
        YAMax = 130;
        YAMin = 0;
            
        Items = new List<ColumnItem>();
            
        Items.Add(new ColumnItem(34.45, 1));
        Items.Add(new ColumnItem(33.45, 2));
        Items.Add(new ColumnItem(32.45, 3));
        Items.Add(new ColumnItem(44.45, 4));
        Items.Add(new ColumnItem(43.45, 5));
        Items.Add(new ColumnItem(42.45, 6));
    }
}
Code behind XAML:
public partial class Window1 : Window
{
    private MainWindowDataContext _mdc;
        
    public Window1()
    {
        _mdc = new MainWindowDataContext();
        this.DataContext = this._mdc;
                        
         InitializeComponent();
    }
}
There are no columns. But there are six sections on the X-axis - so the plot sees my items.
What's wrong with that?

Thanks,
mirola
Coordinator
Apr 25, 2014 at 9:37 AM
I think there is a bug here. As a workaround, try adding a category axis!
https://oxyplot.codeplex.com/workitem/10185
Coordinator
Apr 25, 2014 at 8:00 PM
The issue should be solved. There was a bug when setting ItemsSource to a list of ColumnItem/BarItem...
Apr 26, 2014 at 1:44 PM
Hi objo,

thank you!

Where to download the fixed version? The current recommended download is still the one from the first of march.

Thanks,
mirola
Coordinator
Apr 28, 2014 at 6:40 AM
I forgot to enable the release packaging again, thanks for reminding me about this! I have also reduced the download to the essentials - reducing the size from 17 Mb to 900kb. Note that this library is updated frequently - using the NuGet packages is recommended!