CategoryAxis Exception Thrown

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

bsguedes wrote at 2012-04-18 17:16:


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!



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
myGrid.Children.Add(new OxyPlot.Wpf.Plot { Model = plot };

objo wrote at 2012-04-18 21:01:

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).

bsguedes wrote at 2012-04-18 21:17:

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