SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hi,
I observed a weird behavior with custom pointmarkers in SciChart. The issue is related to the previous one I reported, so I will not post my code snippets here, because it’s actually the same code as in the link. However, it is a different kind of issue, so I thought I should start a new thread.
Description (I attached a .gif to illustrate the issue):
Inside my RenderSurface, I have some pointmarkers which are filled with a transparent color and others which are filled with the color of the stroke of this pointmarker. Whether or not the pointmarker is filled depends on the IPointMetaData object attached to the point (and the meta data won’t change in any way).
When the chart gets displayed I have 4 pointmarkers visible. All 4 are filled, BUT only the leftmost SHOULD be filled. When I now scroll the chart to the right so that the leftmost pointmarker is not visible anymore the 3 remaining pointmarkers lose their fill and are now displayed as they should. Scrolling the first one back in the get filled again. I can only assume that this is maybe caused by SciChart cacheing some resources internally?
Important: I did only observe this issue with the Direct3D10RenderSurface. Everything works as expected with the other three surface types.
Edit:
seems like the gif animation does not work, so I added two more pictures.
DiaryPointMarker.cs
public class DiaryPointMarker : BasePointMarker
{
private IList<IPointMetadata> _dataPointMetadata;
IList<int> _dataPointIndexes = new List<int>();
private readonly List<Point> _points = new List<Point>();
public bool UseClustering { get; set; }
public bool IndicateCommentWithFill { get; set; }
private IPen2D _lowStrokePen;
private IPen2D _midStrokePen;
private IPen2D _highStrokePen;
private IBrush2D _lowRatingColor;
private IBrush2D _midRatingColor;
private IBrush2D _highRatingColor;
private IBrush2D _noCommentColor;
public Brush LowRatingColor { get; set; }
public Brush MidRatingColor { get; set; }
public Brush HighRatingColor { get; set; }
public override void BeginBatch(IRenderContext2D context, Color? strokeColor, Color? fillColor)
{
_dataPointMetadata = RenderableSeries.DataSeries.Metadata;
_dataPointIndexes = new List<int>();
_points.Clear();
base.BeginBatch(context, strokeColor, fillColor);
}
public override void MoveTo(IRenderContext2D context, double x, double y, int index)
{
if (IsInBounds(x, y))
{
_dataPointIndexes.Add(index);
_points.Add(new Point(x,y));
}
if (UseClustering)
{
base.MoveTo(context,x,y,index);
}
}
public override void EndBatch(IRenderContext2D context)
{
if (UseClustering)
{
base.EndBatch(context);
}
else
{
Draw(context, _points);
context.SetPrimitvesCachingEnabled(false);
}
}
public override void Draw(IRenderContext2D context, IEnumerable<Point> centers)
{
TryCasheResources(context);
var markerLocations = centers.ToArray();
for (int i = 0; i < markerLocations.Length; ++i)
{
var diaryMetaInfo = _dataPointMetadata[_dataPointIndexes[i]] as DiaryPointMetaData;
var center = markerLocations[i];
var strokePen = diaryMetaInfo.Rating < 60
? _lowStrokePen
: diaryMetaInfo.Rating < 80 ? _midStrokePen : _highStrokePen;
var fillBrush = diaryMetaInfo.Rating < 60
? _lowRatingColor
: diaryMetaInfo.Rating < 80 ? _midRatingColor : _highRatingColor;
context.DrawEllipse(
strokePen,
IndicateCommentWithFill ? (String.IsNullOrEmpty(diaryMetaInfo.Comment) ? _noCommentColor : fillBrush) : fillBrush,
center,
Width,
Height
);
}
}
private void TryCasheResources(IRenderContext2D context)
{
_lowStrokePen = _lowStrokePen ?? context.CreatePen(LowRatingColor.ExtractColor(), AntiAliasing, (float)StrokeThickness, Opacity);
_midStrokePen = _midStrokePen ?? context.CreatePen(MidRatingColor.ExtractColor(), AntiAliasing, (float)StrokeThickness, Opacity);
_highStrokePen = _highStrokePen ?? context.CreatePen(HighRatingColor.ExtractColor(), AntiAliasing, (float)StrokeThickness, Opacity);
_lowRatingColor = _lowRatingColor ?? context.CreateBrush(LowRatingColor);
_midRatingColor = _midRatingColor ?? context.CreateBrush(MidRatingColor);
_highRatingColor = _highRatingColor ?? context.CreateBrush(HighRatingColor);
_noCommentColor = _noCommentColor ?? context.CreateBrush(Color.FromArgb(0, 0, 0, 0));
}
}
Hi Matthias
After investigation of your sample, we discovered this is a bug in IRenderContext2D.DrawEllipse (only for DirectX).
This is now fixed in build v4.0.5.8270, which will be in the next nightly build of SciChart.
Thanks for reporting!
PS: The forum attachment issue is also fixed đŸ™‚
Hi Matthias,
We had an issue with forums not downloading attachments. Our dev team is working on this now…
In the meantime, I have seen your gif (retrieved from server :)) and dont know what’s causing it.
You mention you are using a custom point marker. Perhaps you can share the code for that pointmarker here?
Best regards,
Andrew
Please login first to submit.