I am trying to implement the DigitalFastLine Series from the example given in ‘http://support.scichart.com/index.php?/Knowledgebase/Article/View/17224/37/how-to-make-line-series-draw-to-the-right-edge-of-the-chart’
public class LinesEnumerable : IEnumerable<Point>
{
protected readonly IPointSeries _pointSeries;
protected readonly ICoordinateCalculator<double> _xCoordinateCalculator;
protected readonly ICoordinateCalculator<double> _yCoordinateCalculator;
protected readonly bool _isDigitalLine;
/// <summary>
/// Initializes a new instance of the <see cref="LinesEnumerable" /> class.
/// </summary>
/// <param name="pointSeries">The point series.</param>
/// <param name="xCoordinateCalculator">The x coordinate calculator.</param>
/// <param name="yCoordinateCalculator">The y coordinate calculator.</param>
/// <param name="isDigitalLine">if set to <c>true</c> return a digital line .</param>
public LinesEnumerable(IPointSeries pointSeries, ICoordinateCalculator<double> xCoordinateCalculator, ICoordinateCalculator<double> yCoordinateCalculator, bool isDigitalLine)
{
_pointSeries = pointSeries;
_xCoordinateCalculator = xCoordinateCalculator;
_yCoordinateCalculator = yCoordinateCalculator;
_isDigitalLine = isDigitalLine;
}
/// <summary>
/// Returns an enumerator that iterates through a collection.
/// </summary>
/// <returns>
/// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
/// </returns>
public virtual IEnumerator<Point> GetEnumerator()
{
return _isDigitalLine ?
(IEnumerator<Point>)new DigitalLinesIterator(_pointSeries, _xCoordinateCalculator, _yCoordinateCalculator) :
new LinesIterator(_pointSeries, _xCoordinateCalculator, _yCoordinateCalculator);
}
/// <summary>
/// Returns an enumerator that iterates through a collection.
/// </summary>
/// <returns>
/// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
/// </returns>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
However, when I try to do the following:
linesEnumerable = linesEnumerable.Concat(new[] { new Point(viewportWidth, lastYCoordinate) });
it says ‘System.Collections.IEnumerable’ does not contain a definition for ‘Concat’ and the best extension method overload ‘System.Linq.Queryable.Concat(System.Linq.IQueryable, System.Collections.Generic.IEnumerable)’ has some invalid arguments
I already have System.Linq and Collections namespace added
using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Abt.Controls.SciChart;
using Abt.Controls.SciChart.Model.DataSeries;
using Abt.Controls.SciChart.Utility;
using Abt.Controls.SciChart.Visuals;
using Abt.Controls.SciChart.Visuals.Axes;
using Abt.Controls.SciChart.Visuals.RenderableSeries;
using System.Globalization;
using System.Windows.Data;
using Abt.Controls.SciChart.Rendering.Common;
using Abt.Controls.SciChart.Numerics.CoordinateCalculators;
What’s going on here? Can you improve your sample?
Thanks!
- Azrin Sani asked 8 years ago
- You must login to post comments
Hi, Ive managed to figure it out…
You may want to update your code though to avoid others confused with it
Thanks
it should be as follows, ‘< Point >’ was missing infront of ‘as IEnumerable’:
protected override void InternalDraw(IRenderContext2D renderContext, IRenderPassData renderPassData)
{
var pointSeries = CurrentRenderPassData.PointSeries;
// Collate data into points (x1, y1, x2, y2 ...)
var linesEnumerable = new LinesEnumerable(pointSeries, renderPassData.XCoordinateCalculator, renderPassData.YCoordinateCalculator, IsDigitalLine) as IEnumerable<Point>;
// New Code here
if (DrawLineToEnd)
{
var dataToRender = renderPassData.PointSeries;
double viewportWidth = this.GetParentSurface().RenderSurface.ActualWidth;
double lastYDataValue = dataToRender[dataToRender.Count - 1].Y;
double lastYCoordinate = renderPassData.YCoordinateCalculator.GetCoordinate(lastYDataValue);
linesEnumerable = linesEnumerable.Concat(new[] { new Point(viewportWidth, lastYCoordinate) });
}
using (var pen = renderContext.CreatePen(SeriesColor, AntiAliasing, StrokeThickness, Opacity, StrokeDashArray))
{
renderContext.DrawLines(pen, linesEnumerable);
}
}
- Azrin Sani answered 8 years ago
-
Thanks for the heads up, we will update the code!
- You must login to post comments
Please login first to submit.