Graph Issue

1 posts, 0 answers
  1. Aditya
    Aditya avatar
    16 posts
    Member since:
    Jun 2011

    Posted 28 Jun 2011 Link to this post

    I am select the coln from dropdownlist to set x-axies & y-axies .I store  Collection of xAxies & YAxies values  are store in 

    ObservableCollection . ObservableCollection contains the values count but not set to graph.souce

    and given an error Object is not set to Instance of object.

    Code is:----

     

     

    ObservableCollection<GraphData> graphDataColl = new ObservableCollection<GraphData>();

     

    graphDataColl.Clear();

     

     

    string xAxisValue = string.Empty;

     

     

     

    string yAxisValue = string.Empty;

     

     

     

     

    if ((xAxies.SelectedItem != null) && (yAxies.SelectedItem != null))

     

    {

    xAxisValue = xAxies.SelectedItem.ToString();

    yAxisValue = yAxies.SelectedItem.ToString();

     

     

    if ((xAxisValue != null) && (yAxisValue != null))

     

    {

     

     

    DataTable dt = (DataTable)radGrV.ItemsSource;

     

     

     

    if (this.chart.Series != null && this.chart.Series.Any())

     

    {

     

     

    foreach (var row in dt.Rows)

     

    {

    graphDataColl.Add(

     

    new GraphData

     

    {

    XAxis =

     

    Convert.ToInt32(row[xAxisValue]),

     

    YAxis =

     

    Convert.ToInt32(row[yAxisValue])

     

    });

    }

     

     

    var currentChart = (this.chart.Series[0] as System.Windows.Controls.DataVisualization.Charting.ColumnSeries);

     

    currentChart.DependentValuePath = xAxisValue;

    currentChart.IndependentValuePath = yAxisValue;

     

    currentChart.ItemsSource = graphDataColl;

     

     

    }

    }

    }

    and xmal code is

     

     

     

     

    <toolkit:Chart x:Name="chart" Grid.Row="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,0" MinWidth="300" MinHeight="500" >

     

     

     

     

     

     

     

     

    <toolkit:Chart.Series >

     

     

     

     

     

     

     

     

    <toolkit:ColumnSeries/>

     

     

     

     

     

     

     

     

    </toolkit:Chart.Series>

     

     

     

     

     

     

     

     

    </toolkit:Chart>

     


    What's going wrong.....

Back to Top