This is a migrated thread and some comments may be shown as answers.

Graph Issue

0 Answers 18 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Aditya
Top achievements
Rank 1
Aditya asked on 28 Jun 2011, 01:59 PM
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.....

No answers yet. Maybe you can help?

Tags
Chart
Asked by
Aditya
Top achievements
Rank 1
Share this question
or