Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2275
Series data all in same bar instead of each one
posted

I'm doing a column chart and all of me series data is in the same series instead of each one.

I'm doing this dynamically.  Here is my code behind:

		private void FillUFChartSeries( Treatment CurrentTreatment )
		{
			try
			{
				ColumnSeries series;
 
				UFStackSeries UFStackSeriesSet = new UFStackSeries( CurrentTreatment );
 
				NumericYAxis yAxis = new NumericYAxis();
				CategoryXAxis xAxis = new CategoryXAxis();
				xAxis.ItemsSource = UFStackSeriesSet;
				xAxis.Label = "{SeriesName}";
				this.UFChart.Axes.Add( xAxis );
				this.UFChart.Axes.Add( yAxis );
 
				foreachUFChartDataSeries CurrentUFChartDataItem in UFStackSeriesSet )
				{
					series = new ColumnSeries();
					series.ItemsSource = CurrentUFChartDataItem.DataPoints;
					series.ValueMemberPath = "DataPointValue";
					series.Title = CurrentUFChartDataItem.SeriesName;
					series.XAxis = xAxis;
					series.YAxis = yAxis;
 
					this.UFChart.Series.Add( series );

				}
			}
			catch ( Exception )
			{
				throw;
			}
		}

Here is the code for how I am structuring the data:

	public class UFStackSeries : ObservableCollection<UFChartDataSeries>
	{
		public UFStackSeries( Treatment CurrentTreatment )
		{
			string SeriesName;
			ObservableCollection<UFChartDataPoint> DataPoints = new ObservableCollection<UFChartDataPoint>();
			foreach ( Cycle c in CurrentTreatment.Cycles )
			{
				SeriesName = "Cycle " + c.CycleIndex.ToString();
				DataPoints = new ObservableCollection<UFChartDataPoint>();
				DataPoints.Add( new UFChartDataPoint()
				{
					DataPointValue = c.UFVolume
				} );
 
				this.Add( new UFChartDataSeries()
				{
					SeriesName = SeriesName,
					DataPoints = DataPoints
				} );
			}
		}
	}
 
	/// 
	/// Data series for the UFChart
	/// 
	public class UFChartDataSeries
	{
		public string SeriesName
		{
			get;
			set;
		}
 
		public ObservableCollection<UFChartDataPoint> DataPoints
		{
			get;
			set;
		}
	}

What I want is for each cycle to have it's own data, but all the data is being put into cycle 0, and there are spots for all of the cycles, but they don't have any data put in them.

Here is what the graph actually looks like:

Thanks,

Mike

Parents Reply Children