How to bind data to OxyPlot Column Chart?

AjayKumar.MAjayKumar.M USMember ✭✭

I'm using below code to generate the column chart

PlotView plotView = new PlotView ();
var plotModel1 = new PlotModel();
plotModel1.Subtitle = "The items are defined by a List of BarItem/ColumnItem";
plotModel1.Title = "Binding to ItemsSource";
var categoryAxis1 = new CategoryAxis();
categoryAxis1.MinorStep = 1;
categoryAxis1.Labels.Add("1");
categoryAxis1.Labels.Add("2");
categoryAxis1.ActualLabels.Add("1");
categoryAxis1.ActualLabels.Add("2");
plotModel1.Axes.Add(categoryAxis1);
var linearAxis1 = new LinearAxis();
linearAxis1.MinimumPadding = 0;
plotModel1.Axes.Add(linearAxis1);
var columnSeries1 = new ColumnSeries();
columnSeries1.Title = "Series 1";
plotModel1.Series.Add(columnSeries1);
plotView.Model = plotModel1;

Please help me on how to bind the data?

Tagged:

Posts

  • Naresh.2672Naresh.2672 USMember
    edited July 2015

    small question, are you doing it in codebehind or using MVVM?

    one issue : you don't have Items added to columnSeries1

  • rmarinhormarinho PTMember, Insider, Beta Xamurai

    You can bind the Model property only.

  • AjayKumar.MAjayKumar.M USMember ✭✭

    @Naresh.2672
    I'm using MVVM to bind the chart. How can I?

  • Naresh.2672Naresh.2672 USMember
    edited July 2015

    Create a PlotModel property and bind that property to Model of PlotView in xaml

    PlotView Model={Binding PlotModel}

Sign In or Register to comment.