3
默認LineSeries實現通過獨立值對數據點進行排序。這讓我對這樣的數據奇怪的結果:WPF工具包Chart無序LineSeries
是否有可能繪製線系列,其中線點之間的原始順序繪製?
class UnorderedLineSeries : LineSeries
{
protected override void UpdateShape()
{
double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(
ActualDependentRangeAxis.Range.Maximum).Value;
Func<DataPoint, Point> PointCreator = dataPoint =>
new Point(
ActualIndependentAxis.GetPlotAreaCoordinate(
dataPoint.ActualIndependentValue).Value,
maximum - ActualDependentRangeAxis.GetPlotAreaCoordinate(
dataPoint.ActualDependentValue).Value);
IEnumerable<Point> points = Enumerable.Empty<Point>();
if (CanGraph(maximum))
{
// Original implementation performs ordering here
points = ActiveDataPoints.Select(PointCreator);
}
UpdateShapeFromPoints(points);
}
bool CanGraph(double value)
{
return !double.IsNaN(value) &&
!double.IsNegativeInfinity(value) &&
!double.IsPositiveInfinity(value) &&
!double.IsInfinity(value);
}
}
結果:
解決我的問題太多,謝謝! – tdc 2013-05-01 14:32:37
你在哪裏使用該代碼? – FrancescoDS 2015-02-04 17:57:37
@FrancescoDS,它已經晚了一年多,但我已經在下面粘貼瞭如何使用它。 :) – XtraSimplicity 2016-05-05 05:04:29