Hi, I've setup a line series with the x axis as a category axis like so:
When I bind the chart with this code, the chart is drawn properly except for the x axis which shows numbers instead for the text it is suppose to bind to: (see the attached file, it is a screen shot of the chart)
Please help!
Michel
SeriesMapping seriesMapping =
new
SeriesMapping();
LineSeriesDefinition redLineSeries =
new
LineSeriesDefinition();
LineSeriesDefinition blackLineSeries =
new
LineSeriesDefinition();
LineSeriesDefinition orangeLineSeries =
new
LineSeriesDefinition();
redLineSeries.ShowPointMarks =
false
;
redLineSeries.ShowItemLabels =
false
;
redLineSeries.Appearance.StrokeThickness = 1;
redLineSeries.Appearance.Stroke =
new
System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
blackLineSeries.ShowPointMarks =
false
;
blackLineSeries.ShowItemLabels =
false
;
blackLineSeries.Appearance.StrokeThickness = 1;
blackLineSeries.Appearance.Stroke =
new
System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
orangeLineSeries.ShowPointMarks =
false
;
orangeLineSeries.ShowItemLabels =
false
;
orangeLineSeries.Appearance.StrokeThickness = 1;
orangeLineSeries.Appearance.Stroke =
new
System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Orange);
seriesMapping =
new
SeriesMapping();
seriesMapping.SeriesDefinition = orangeLineSeries;
seriesMapping.LegendLabel =
"ML Historical"
;
seriesMapping.ItemMappings.Add(
new
ItemMapping(
"RealResultValue"
, DataPointMember.YValue));
seriesMapping.ItemMappings.Add(
new
ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName =
"start_time_text"
});
radChart.SeriesMappings.Add(seriesMapping);
seriesMapping =
new
SeriesMapping();
seriesMapping.SeriesDefinition = blackLineSeries;
seriesMapping.LegendLabel =
"ML"
;
seriesMapping.ItemMappings.Add(
new
ItemMapping(
"ResultValue"
, DataPointMember.YValue));
seriesMapping.ItemMappings.Add(
new
ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName =
"start_time_text"
});
radChart.SeriesMappings.Add(seriesMapping);
seriesMapping =
new
SeriesMapping();
seriesMapping.SeriesDefinition = redLineSeries;
seriesMapping.LegendLabel =
"Max Failure"
;
seriesMapping.ItemMappings.Add(
new
ItemMapping(
"MaxFailure"
, DataPointMember.YValue));
seriesMapping.ItemMappings.Add(
new
ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName =
"start_time_text"
});
radChart.SeriesMappings.Add(seriesMapping);
seriesMapping =
new
SeriesMapping();
seriesMapping.SeriesDefinition = redLineSeries;
seriesMapping.LegendLabel =
"Min Failure"
;
seriesMapping.ItemMappings.Add(
new
ItemMapping(
"MinFailure"
, DataPointMember.YValue));
seriesMapping.ItemMappings.Add(
new
ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName =
"start_time_text"
});
radChart.SeriesMappings.Add(seriesMapping);
radChart.DefaultView.ChartArea.AxisX.AxisStyles.TickLineStyle = (Style)
this
.Resources[
"AxisXTickStyle"
];
radChart.DefaultView.ChartArea.AxisX.Title =
"Date and time"
;
radChart.DefaultView.ChartArea.AxisX.IsDateTime =
false
;
radChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = -90;
radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Normal;
When I bind the chart with this code, the chart is drawn properly except for the x axis which shows numbers instead for the text it is suppose to bind to: (see the attached file, it is a screen shot of the chart)
statData = ec.StatDatas.ToList();
if
(statData.Count > 0 && lsbVariable.SelectedItem !=
null
&& ((TestVariable)lsbVariable.SelectedItem).load)
{
radChart.SeriesMappings[1].LegendLabel = ((TestVariable)lsbVariable.SelectedItem).caption;
radChart.SeriesMappings[0].LegendLabel = ((TestVariable)lsbVariable.SelectedItem).caption +
" Historical"
;
radChart.DefaultView.ChartArea.AxisY.Title = ((TestVariable)lsbVariable.SelectedItem).caption;
radChart.DefaultView.ChartArea.AxisX.LabelStep = (
int
)(statData.Where(d => d.test_id.Equals(((TestVariable)lsbVariable.SelectedItem).test_id) && d.variable_id.Equals(((TestVariable)lsbVariable.SelectedItem).variable_id)).Count() / (radChart.DefaultView.ChartArea.ActualWidth / 25));
radChart.ItemsSource = statData.Where(d => d.test_id.Equals(((TestVariable)lsbVariable.SelectedItem).test_id) && d.variable_id.Equals(((TestVariable)lsbVariable.SelectedItem).variable_id));
SetupStat(statData.Where(d => d.test_id.Equals(((TestVariable)lsbVariable.SelectedItem).test_id) && d.variable_id.Equals(((TestVariable)lsbVariable.SelectedItem).variable_id)).ToList());
//SetupStatus();
}
Please help!
Michel