I have three charts to display based on user selection. They are each similar and based on similar data. I am using the VisualStateManagerr to change which one is shown. If I process like ten items (corresponding to ten series), all three show correctly. If I do 20, the first one does and the other 2 do not show series although the series mappings are there and the legend shows their headings. If I do 15, the first and second charts show their series and the third does not. My first thought is memory related but I know telerik controls are sharing resources under the hood. Any idea?
private void cboSeries_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
string state = "OAS";
ComboBoxItem cbi = null;
if (cboSeries != null)
cbi = cboSeries.SelectedItem as ComboBoxItem;
if (cbi != null)
if ("USD Equivalent Spread".Equals(cbi.Content.ToString()))
state = "USDEquivSpread";
else
if ("OAS".Equals(cbi.Content.ToString()))
state = "OAS";
else
state = "Basis";
VisualStateManager.GoToState(this, state, true);
}
public void ProcessRadChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
Clear();
ProcessOASHistoryChart(results);
ProcessUSDEquivChart(results);
ProcessBasisChart(results);
//Background thread and GUI, oh no
//Thread OASThread = new Thread(delegate() { ProcessOASHistoryChart(results); });
//Thread USDThread = new Thread(delegate() { ProcessUSDEquivChart(results); });
//Thread BasThread = new Thread(delegate() { ProcessBasisChart(results); });
//OASThread.Start();
//USDThread.Start();
//BasThread.Start();
//while (OASThread.IsAlive && USDThread.IsAlive && BasThread.IsAlive)
//{
//}
if (ProcessedOAS != null)
ProcessedOAS(this, new EventArgs());
}
public void ProcessOASHistoryChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radOASHistory.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radOASHistory.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.OAS != null) && (result.OAS.Count > 0))
{
if (result.OAS.Min(rung => rung.PriceDate) < minDates[0])
minDates[0] = result.OAS.Min(rung => rung.PriceDate);
}
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
if ((result.Basis != null) && (result.Basis.Count > 0))
{
if (result.Basis.Min(rung => rung.PriceDate) < minDates[2])
minDates[2] = result.Basis.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radOASHistory.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radOASHistory.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radOASHistory.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radOASHistory.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.OAS;
radOASHistory.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radOASHistory.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}
public void ProcessUSDEquivChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radUSDEquivHistory.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radUSDEquivHistory.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radUSDEquivHistory.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radUSDEquivHistory.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radUSDEquivHistory.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radUSDEquivHistory.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.USDEquivSpread;
radUSDEquivHistory.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radUSDEquivHistory.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}
public void ProcessBasisChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radBasis.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radBasis.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radBasis.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radBasis.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radBasis.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radBasis.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.USDEquivSpread;
radBasis.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radBasis.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}
private void cboSeries_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
string state = "OAS";
ComboBoxItem cbi = null;
if (cboSeries != null)
cbi = cboSeries.SelectedItem as ComboBoxItem;
if (cbi != null)
if ("USD Equivalent Spread".Equals(cbi.Content.ToString()))
state = "USDEquivSpread";
else
if ("OAS".Equals(cbi.Content.ToString()))
state = "OAS";
else
state = "Basis";
VisualStateManager.GoToState(this, state, true);
}
public void ProcessRadChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
Clear();
ProcessOASHistoryChart(results);
ProcessUSDEquivChart(results);
ProcessBasisChart(results);
//Background thread and GUI, oh no
//Thread OASThread = new Thread(delegate() { ProcessOASHistoryChart(results); });
//Thread USDThread = new Thread(delegate() { ProcessUSDEquivChart(results); });
//Thread BasThread = new Thread(delegate() { ProcessBasisChart(results); });
//OASThread.Start();
//USDThread.Start();
//BasThread.Start();
//while (OASThread.IsAlive && USDThread.IsAlive && BasThread.IsAlive)
//{
//}
if (ProcessedOAS != null)
ProcessedOAS(this, new EventArgs());
}
public void ProcessOASHistoryChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radOASHistory.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radOASHistory.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.OAS != null) && (result.OAS.Count > 0))
{
if (result.OAS.Min(rung => rung.PriceDate) < minDates[0])
minDates[0] = result.OAS.Min(rung => rung.PriceDate);
}
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
if ((result.Basis != null) && (result.Basis.Count > 0))
{
if (result.Basis.Min(rung => rung.PriceDate) < minDates[2])
minDates[2] = result.Basis.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radOASHistory.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radOASHistory.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radOASHistory.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radOASHistory.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.OAS;
radOASHistory.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radOASHistory.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}
public void ProcessUSDEquivChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radUSDEquivHistory.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radUSDEquivHistory.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radUSDEquivHistory.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radUSDEquivHistory.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radUSDEquivHistory.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radUSDEquivHistory.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.USDEquivSpread;
radUSDEquivHistory.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radUSDEquivHistory.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}
public void ProcessBasisChart(ObservableCollection<PCYAsimServiceHistoryItem> results)
{
if (results == null ||
results.Count == 0)
return;
try
{
radBasis.DefaultView.ChartArea.PlotAreaStyle = this.BackgroundStyle;
//For single series charts only, ie. TwoFactor or MultiBond with one bond
if (results.Count == 1)
{
LinearGradientBrush areaBrush = new LinearGradientBrush();
areaBrush.Opacity = 0.5;
GradientStop stop1 = new GradientStop();
stop1.Offset = 0.5;
stop1.Color = new Color{A=0, R=111, G=110, B=0};
GradientStop stop2 = new GradientStop();
stop2.Offset = 0.5;
stop2.Color = new Color{A=0, R=0, G=0, B=139};
areaBrush.GradientStops.Add(stop1);
areaBrush.GradientStops.Add(stop2);
radBasis.DefaultView.ChartArea.Background = areaBrush;
}
DateTime max = DateTime.MinValue;
DateTime[] minDates = new DateTime[] { DateTime.MaxValue, DateTime.MaxValue, DateTime.MaxValue };
foreach (PCYAsimServiceHistoryItem result in results)
{
if (result.AsofDate > max)
max = result.AsofDate;
if ((result.USDEquivSpread != null) && (result.USDEquivSpread.Count > 0))
{
if (result.USDEquivSpread.Min(rung => rung.PriceDate) < minDates[1])
minDates[1] = result.USDEquivSpread.Min(rung => rung.PriceDate);
}
}
max = max.AddDays(14);
DateTime min = minDates.Min();
radBasis.DefaultView.ChartArea.AxisX.MinValue = min.ToOADate();
radBasis.DefaultView.ChartArea.AxisX.MaxValue = max.ToOADate();
Brush gridLineStroke = new SolidColorBrush(System.Windows.Media.Colors.White);
AnnotationCollection ac = new AnnotationCollection();
DateTime dttick = min;
while (dttick < max)
{
if (dttick.Day == 1)
{
ac.Add(new CustomGridLine { XIntercept = dttick.ToOADate(), Stroke = gridLineStroke, StrokeThickness = 1, Opacity = 0.5 });
}
dttick = dttick.AddDays(1);
}
radBasis.DefaultView.ChartArea.Annotations = ac;
_data = results;
for (int idx = 0; idx < results.Count; idx++)
{
PCYAsimServiceHistoryItem hi = results[idx];
SeriesMapping seriesMapping = new SeriesMapping();
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = hi.Description;
SolidColorBrush lineColor;
if (idx < Colors.Length)
lineColor = new SolidColorBrush(Colors[idx]);
else
lineColor = new SolidColorBrush(GenerateRandomColor());
legendItem.Foreground = lineColor;
legendItem.MarkerFill = lineColor;
radBasis.DefaultView.ChartLegend.Items.Add(legendItem);
LineSeriesDefinition line = new LineSeriesDefinition
{
ShowItemLabels = false,
ShowPointMarks = false,
ShowItemToolTips = true,
Appearance = { Stroke = lineColor, Fill = lineColor },
AxisName = "RightYAxis",
ItemToolTipFormat = "#X{d} - #Y{N0}",
};
seriesMapping.SeriesDefinition = line;
seriesMapping.ItemMappings.Add(new ItemMapping("PriceDate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
seriesMapping.ItemsSource = hi.USDEquivSpread;
radBasis.SeriesMappings.Add(seriesMapping);
}
// get the axes to layout
radBasis.UpdateLayout();
}
catch (Exception ex)
{
throw ex;
}
}