Reputation: 957
I have a fast-line chart series where on X I have DateTime
and on Y double
values - series is added to the chart with such method:
public virtual bool AddOrUpdateSeries(int caIndex, Series newSeries, bool visibleInLegend)
{
var chartArea = GetChartArea(caIndex);
if (chartArea == null) return false;
var existingSeries = _chart.Series.FirstOrDefault(s => s.Name == newSeries.Name);
if (existingSeries != null)
{
existingSeries.Points.Clear();
AddPoints(newSeries.Points, existingSeries);
}
else
{
newSeries.ChartArea = chartArea.Name;
newSeries.Legend = chartArea.Name;
newSeries.IsVisibleInLegend = visibleInLegend;
newSeries.BorderWidth = 2;
newSeries.EmptyPointStyle = new DataPointCustomProperties { Color = Color.Red };
_chart.Series.Add(newSeries);
}
return true;
}
As you can see, I am setting the style for empty point to be shown in red.
The first points that are added to the series are as follows:
So as you can see, first two points have the same Y value, but in addition -
first one has IsEmpty
flag set.
Empty point is added to the series with such piece of code:
series.Points.Add(new DataPoint
{
XValue = _beginOADate,
YValues = new[] { firstDbPoint.Y },
IsEmpty = true
});
where _beginOADate
is double OADate value = 42563
= 12/07/2016 00:00 as DateTime
.
The second point's DateTime
is 15/08/2016 22:20
When chart is displayed with the beginning of the X axis, everything looks ok as on the picture below - empty datapoint starts at 12/07/2016 and lasts until 15/08/2016.
But, when I scroll one position on X, the empty datapoint's red line is not being displayed - instead, whole visible part of empty datapoint's line is displayed as it is non-empty:
Anybody knows how to fix this behaviour so that the whole line starting from Empty datapoint until first non-empty datapoint would always be shown in red?
Of course the dummy solution would be to add one more extra empty datapoint very close to the first non-empty point, but I don't like that solution.
Upvotes: 2
Views: 608
Reputation: 54433
The ChartType.FastLine
is much faster the the simple Line
chart but to be so fast it makes several simplifications in rendering, which means that not all chart features are supported:
The FastLine chart type is a variation of the Line chart that significantly reduces the drawing time of a series that contains a very large number of data points. Use this chart in situations where very large data sets are used and rendering speed is critical.
Some charting features are omitted from the FastLine chart to improve performance. The features omitted include control of point level visual attributes, markers, data point labels, and shadows.
Unfortunately EmptyPointStyle
is such a 'point level visual attribute'.
So you will need to decide which is more important: The raw speed or the direct and plausible treatment of empty DataPoints
.
(I have a hunch that you'll go for your 'dummy solution', which imo is a 1st class workaround ;-)
Upvotes: 2