public CartesianChartCore(ICartesianChartView <TDrawingContext> view, Canvas <TDrawingContext> canvas) { this.canvas = canvas; chartView = view; updateThrottler = new ActionThrottler(TimeSpan.FromSeconds(300)); updateThrottler.Unlocked += UpdateThrottlerUnlocked; }
/// <summary> /// Initializes a new instance of the <see cref="CartesianChart"/> class. /// </summary> /// <param name="tooltip">The default tool tip control.</param> /// <param name="legend">The default legend control.</param> public CartesianChart(IChartTooltip <SkiaSharpDrawingContext>?tooltip = null, IChartLegend <SkiaSharpDrawingContext>?legend = null) : base(tooltip, legend) { seriesObserver = new CollectionDeepObserver <ISeries>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); xObserver = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); yObserver = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); XAxes = new List <IAxis>() { new Axis() }; YAxes = new List <IAxis>() { new Axis() }; Series = new ObservableCollection <ISeries>(); var c = Controls[0].Controls[0]; c.MouseWheel += OnMouseWheel; c.MouseDown += OnMouseDown; c.MouseMove += OnMoseMove; c.MouseUp += OnMouseUp; panningThrottler = new ActionThrottler(DoPan, TimeSpan.FromMilliseconds(30)); }
public CartesianChart() { SizeChanged += OnSizeChanged; MouseMove += OnMouseMove; mouseMoveThrottler = new ActionThrottler(TimeSpan.FromMilliseconds(10)); mouseMoveThrottler.Unlocked += MouseMoveThrottlerUnlocked; }
public Chart() { motionCanvas = new MotionCanvas(); SuspendLayout(); motionCanvas.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; motionCanvas.FramesPerSecond = 90D; motionCanvas.Location = new Point(0, 0); motionCanvas.Name = "motionCanvas"; motionCanvas.Size = new Size(150, 150); motionCanvas.TabIndex = 0; motionCanvas.Resize += OnResized; motionCanvas.MouseMove += OnMouseMove; AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; Controls.Add(motionCanvas); Name = "CartesianChart"; ResumeLayout(false); if (!LiveCharts.IsConfigured) { LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); } var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <SkiaSharpDrawingContext>(); var initializer = stylesBuilder.GetInitializer(); if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0) { throw new Exception("Default colors are not valid"); } initializer.ConstructChart(this); InitializeCore(); mouseMoveThrottler = new ActionThrottler(MouseMoveThrottlerUnlocked, TimeSpan.FromMilliseconds(10)); }
public async Task MultipleThreads() { var runs = 0; Action action = () => { runs++; }; var throttler = new ActionThrottler(action, TimeSpan.FromMilliseconds(50)); new Thread(() => throttler.Call()).Start(); new Thread(() => throttler.Call()).Start(); new Thread(() => throttler.Call()).Start(); await Task.WhenAll( Task.Factory.StartNew(() => throttler.Call()), Task.Factory.StartNew(() => throttler.Call()), Task.Factory.StartNew(() => throttler.Call()), Task.Run(() => throttler.Call()), Task.Run(() => throttler.Call()), Task.Run(() => throttler.Call())); await Task.Delay(TimeSpan.FromSeconds(0.5)); var calls = throttler.Calls; Assert.IsTrue(runs == 1 && throttler.Calls == 9); }
public ChartCore(IChartView <TDrawingContext> view, Canvas <TDrawingContext> canvas) { naturalGeometriesCanvas = canvas; chartView = view; updateThrottler = new ActionThrottler(TimeSpan.FromSeconds(300)); updateThrottler.Unlocked += UpdateThrottlerUnlocked; }
public Chart(MotionCanvas <TDrawingContext> canvas, Action <LiveChartsSettings> defaultPlatformConfig) { this.canvas = canvas; updateThrottler = new ActionThrottler(TimeSpan.FromSeconds(300)); updateThrottler.Unlocked += UpdateThrottlerUnlocked; easingFunction = EasingFunctions.QuadraticOut; if (!LiveCharts.IsConfigured) { LiveCharts.Configure(defaultPlatformConfig); } }
public CartesianChart() { InitializeComponent(); if (!LiveCharts.IsConfigured) { LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); } var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <SkiaSharpDrawingContext>(); var initializer = stylesBuilder.GetInitializer(); if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0) { throw new Exception("Default colors are not valid"); } initializer.ConstructChart(this); InitializeCore(); SizeChanged += OnSizeChanged; mouseMoveThrottler = new ActionThrottler(MouseMoveThrottlerUnlocked, TimeSpan.FromMilliseconds(10)); seriesObserver = new CollectionDeepObserver <ISeries>( (object sender, NotifyCollectionChangedEventArgs e) => { if (core == null) { return; } MainThread.BeginInvokeOnMainThread(core.Update); }, (object sender, PropertyChangedEventArgs e) => { if (core == null) { return; } MainThread.BeginInvokeOnMainThread(core.Update); }, true); XAxes = new List <IAxis>() { new Axis() }; YAxes = new List <IAxis>() { new Axis() }; Series = new ObservableCollection <ISeries>(); }
public PieChart() { InitializeComponent(); if (!LiveCharts.IsConfigured) { LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); } var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <SkiaSharpDrawingContext>(); var initializer = stylesBuilder.GetInitializer(); if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0) { throw new Exception("Default colors are not valid"); } initializer.ConstructChart(this); InitializeCore(); mouseMoveThrottler = new ActionThrottler(MouseMoveThrottlerUnlocked, TimeSpan.FromMilliseconds(10)); seriesObserver = new CollectionDeepObserver <ISeries>( (object?sender, NotifyCollectionChangedEventArgs e) => { if (core == null) { return; } Dispatcher.UIThread.InvokeAsync(core.Update, DispatcherPriority.Background); }, (object?sender, PropertyChangedEventArgs e) => { if (core == null) { return; } Dispatcher.UIThread.InvokeAsync(core.Update, DispatcherPriority.Background); }); Series = new ObservableCollection <ISeries>(); }
public Chart() { if (!LiveCharts.IsConfigured) { LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); } var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <SkiaSharpDrawingContext>(); var initializer = stylesBuilder.GetInitializer(); if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0) { throw new Exception("Default colors are not valid"); } initializer.ConstructChart(this); SizeChanged += OnSizeChanged; MouseMove += OnMouseMove; mouseMoveThrottler = new ActionThrottler(TimeSpan.FromMilliseconds(10)); mouseMoveThrottler.Unlocked += MouseMoveThrottlerUnlocked; }
public async Task SameThread() { var runs = 0; Action action = () => { runs++; }; var throttler = new ActionThrottler(action, TimeSpan.FromMilliseconds(50)); throttler.Call(); throttler.Call(); throttler.Call(); throttler.Call(); throttler.Call(); throttler.Call(); await Task.Delay(TimeSpan.FromSeconds(0.5)); Assert.IsTrue(runs == 1 && throttler.Calls == 6); }
/// <summary> /// Initializes a new instance of the <see cref="CartesianChart"/> class. /// </summary> public CartesianChart() { _seriesObserver = new CollectionDeepObserver <ISeries>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); _xObserver = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); _yObserver = new CollectionDeepObserver <IAxis>(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); SetCurrentValue(XAxesProperty, new List <IAxis>() { new Axis() }); SetCurrentValue(YAxesProperty, new List <IAxis>() { new Axis() }); SetCurrentValue(SeriesProperty, new ObservableCollection <ISeries>()); MouseWheel += OnMouseWheel; MouseDown += OnMouseDown; MouseMove += OnMouseMove; MouseUp += OnMouseUp; _panningThrottler = new ActionThrottler(DoPan, TimeSpan.FromMilliseconds(30)); }