Hello,
I have a small problem.
As the data source of the chart I am using a DataTable because the DataSeries can be added dynamically.
Therefore it was the easiest way for me.
The DataTable has the following structure
- Timestamp : DateTime
- Value1 : double
- Value2 : double
The problem is that in my case it is possible that a few rows have Value1 or Value2 = null because there was no value at this timestamp.
The chart displays this null value as 0. But for me it would be nice if it just ignores the null value
I created a small example which shows the problem:
When you try this you will see that the second Series looks a bit strange because it added 0 instead of ignoring the null value.
Is there a workaround for that?
How can I fix this problem?
I am using Version: 2010.3.1110.35
Kind Regards
Michael
I have a small problem.
As the data source of the chart I am using a DataTable because the DataSeries can be added dynamically.
Therefore it was the easiest way for me.
The DataTable has the following structure
- Timestamp : DateTime
- Value1 : double
- Value2 : double
The problem is that in my case it is possible that a few rows have Value1 or Value2 = null because there was no value at this timestamp.
The chart displays this null value as 0. But for me it would be nice if it just ignores the null value
I created a small example which shows the problem:
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
var dt =
new
DataTable();
dt.Columns.Add(
"Timestamp"
,
typeof
(DateTime));
dt.Columns.Add(
"Value1"
,
typeof
(
double
));
dt.Columns.Add(
"Value2"
,
typeof
(
double
));
for
(
int
i = 0; i < 20; i++)
{
var obj =
new
object
[3];
obj[0] = DateTime.Now.AddHours(i);
obj[1] = i;
if
(i % 2 != 0)
obj[2] = i + 1;
else
obj[2] =
null
;
dt.Rows.Add(obj);
}
chart.ItemsSource = dt;
SeriesMapping seriesMapping =
new
SeriesMapping();
seriesMapping.SeriesDefinition =
new
LineSeriesDefinition();
seriesMapping.ItemMappings.Add(
new
ItemMapping
{
DataPointMember = DataPointMember.XValue,
FieldName =
"Timestamp"
,
FieldType =
typeof
(DateTime)
});
seriesMapping.ItemMappings.Add(
new
ItemMapping
{
DataPointMember = DataPointMember.YValue,
FieldName =
"Value1"
,
FieldType =
typeof
(
double
)
});
chart.SeriesMappings.Add(seriesMapping);
SeriesMapping seriesMapping1 =
new
SeriesMapping();
seriesMapping1.SeriesDefinition =
new
LineSeriesDefinition();
seriesMapping1.ItemMappings.Add(
new
ItemMapping
{
DataPointMember = DataPointMember.XValue,
FieldName =
"Timestamp"
,
FieldType =
typeof
(DateTime)
});
seriesMapping1.ItemMappings.Add(
new
ItemMapping
{
DataPointMember = DataPointMember.YValue,
FieldName =
"Value2"
,
FieldType =
typeof
(
double
)
});
chart.SeriesMappings.Add(seriesMapping1);
}
}
When you try this you will see that the second Series looks a bit strange because it added 0 instead of ignoring the null value.
Is there a workaround for that?
How can I fix this problem?
I am using Version: 2010.3.1110.35
Kind Regards
Michael