CategoryAxis Exception Thrown

Apr 18, 2012 at 3:16 PM
Edited Apr 18, 2012 at 5:29 PM

Hello,

First of all congratulations for the excellent library! I searched a lot for WPF good charting libraries and I have finally found one!

I'm having an issue trying to plot the BarSeries example. The following exception is thrown: "The y-axis should be a CategoryAxis."

I don't know if I have got it right, but isn't the X axis supposed to be a Category axis? The y-axis would be a linear axis showing the values of each bar for each label, am I right?

Thanks for any help!

Bruno

 

EDIT: ok, when I run the project BarSeriesDemo it works... I don't understand why we have to set DataContext = this in that example (as it won't work without that line). Could I plot a bar graph the same way I plot a Line graph, i.e., something like this:

var plot = new PlotModel();
// create axes...etc...
var lineSeries = new LineSeries(myLabel);
// fills lineSeries with my Data
plot.Series.Add(lineSeries);
myGrid.Children.Add(new OxyPlot.Wpf.Plot { Model = plot };

Coordinator
Apr 18, 2012 at 7:01 PM

The BarSeries is horizontal, the ColumnSeries is vertical.

I will improve the exception message to give more information about this.

It is also important to fill the category labels (the Labels list property, or an ItemsSource and a LabelField) with the same number of items as in the bar/column series. 

More documentation on this is coming later as soon as I get time. See the examples.

You need to set the DataContext in order for the binding to the plot model to work (this is standard wpf).

Apr 18, 2012 at 7:17 PM

Thanks for the quick answer! ColumnSeries works fine for me!