ColumnSeries

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

mirola wrote at 2014-04-20 16:00:

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

objo wrote at 2014-04-25 11:37:

I think there is a bug here. As a workaround, try adding a category axis!
https://oxyplot.codeplex.com/workitem/10185

objo wrote at 2014-04-25 22:00:

The issue should be solved. There was a bug when setting ItemsSource to a list of ColumnItem/BarItem...

mirola wrote at 2014-04-26 15:44:

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

objo wrote at 2014-04-28 08:40:

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!