when i custom PointMarker, the DoubleAnimation not effect on using LineRenderableSeriesViewModel.
But it was effect on using FastLineRenderableSeries in xaml.
using SciChart.Charting.Visuals.PointMarkers;
using SciChart.Charting.Visuals.RenderableSeries;
using SciChart.Drawing.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace SciChart_DatapointMarkers
{
public class CustomEllipsePointMarker : EllipsePointMarker
{
private readonly Storyboard storyboard = new Storyboard();
private double lastYValue = 0;
private double lastXValue = 0;
public CustomEllipsePointMarker()
: base()
{
DoubleAnimation opacityAnimation = new DoubleAnimation();
opacityAnimation.From = 0.8;
opacityAnimation.To = 0.4;
opacityAnimation.AutoReverse = true;
opacityAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
Storyboard.SetTarget(opacityAnimation, this);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(EllipsePointMarker.OpacityProperty));
storyboard.Children.Add(opacityAnimation);
DoubleAnimation widthAnimation = new DoubleAnimation();
widthAnimation.From = 14;
widthAnimation.To = 24;
widthAnimation.AutoReverse = true;
widthAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
Storyboard.SetTarget(widthAnimation, this);
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(EllipsePointMarker.WidthProperty));
storyboard.Children.Add(widthAnimation);
DoubleAnimation heightAnimation = new DoubleAnimation();
heightAnimation.From = 14;
heightAnimation.To = 24;
heightAnimation.AutoReverse = true;
heightAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
Storyboard.SetTarget(heightAnimation, this);
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(EllipsePointMarker.HeightProperty));
storyboard.Children.Add(heightAnimation);
//DoubleAnimation strokeThicknessAnimation = new DoubleAnimation();
//strokeThicknessAnimation.From = 4;
//strokeThicknessAnimation.To = 9;
//strokeThicknessAnimation.AutoReverse = true;
//strokeThicknessAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
//Storyboard.SetTargetProperty(strokeThicknessAnimation, new PropertyPath(EllipsePointMarker.StrokeThicknessProperty));
//storyboard.Children.Add(strokeThicknessAnimation);
}
public override void Draw(IRenderContext2D context, IEnumerable<Point> centers)
{
if (centers == null || centers.Count() <= 0)
{
return;
}
if (this.RenderableSeries != null &&
this.RenderableSeries.DataSeries != null &&
(this.RenderableSeries.DataSeries.LatestYValue.CompareTo(this.lastYValue) != 0 ||
this.RenderableSeries.DataSeries.XMax.CompareTo(this.lastXValue) != 0))
{
this.BeginStoryboard(storyboard);
this.lastYValue = Convert.ToDouble(this.RenderableSeries.DataSeries.LatestYValue);
this.lastXValue = Convert.ToDouble(this.RenderableSeries.DataSeries.XMax);
}
base.Draw(context, new List<Point>() { centers.Last() });
}
protected override void RenderToCache(IRenderContext2D context, IPen2D strokePen, IBrush2D fillBrush)
{
base.RenderToCache(context, strokePen, fillBrush);
var width = context.ViewportSize.Width;
var height = context.ViewportSize.Height;
var brush = context.CreateBrush(this.RenderableSeries.Stroke);
context.DrawEllipse(strokePen, brush, new Point(width * 0.5, height * 0.5), 6, 6);
}
}
}
- sun asked 6 years ago
- You must login to post comments
Hi there,
Thanks for your question. It’s not enough info. Please provide some more info, video, sample. Code of your SciChartSurface, how you set point marker…
SciChart version 4.2 and customization is out of our support scope but if there is something I can do then I will help you.
- Taras Bulka answered 6 years ago
- You must login to post comments
Please login first to submit.