private void SalesPerDaysSeries_ChartPointPointerDown( IChartView chart, ChartPoint <Fruit, BezierPoint <CircleGeometry>, LabelGeometry> point) { Trace.WriteLine( $"[salesPerDay ChartPointPointerDown] clicked on {point.Model.Name}, {point.Model.SalesPerDay} items sold per day"); }
//private readonly IIndexService IndexService; public ChartPresenter(IMainView main, IChartView chart) { this._main = main; this._chart = chart; //this.IndexService = indexer; _main.ChartClick += _main_ChartClick; }
protected override void ConnectFirstLastDataPoints() { IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; PathFigure figure = null; PolyLineSegment lineSegment = null; foreach (Point point in SplineHelper.GetSplinePointsConnectingAbsoluteFirstLastDataPoints(this.renderPoints, scaleFactor)) { if (lineSegment == null) { figure = new PathFigure(); figure.StartPoint = point; lineSegment = new PolyLineSegment(); continue; } lineSegment.Points.Add(point); } if (lineSegment != null) { figure.Segments.Add(lineSegment); this.shapeGeometry.Figures.Add(figure); } }
public double GetLocationOfValue(object value, NumericalAxis axis) { NumericalAxisModel model = axis.Model as NumericalAxisModel; double val = Convert.ToDouble(value); val = (double)model.TransformValue(val); double delta = axis.ActualRange.Maximum - axis.ActualRange.Minimum; double normalizedValue = (val - axis.ActualRange.Minimum) / delta; IChartView view = (IChartView)axis.View; CartesianArea area = axis.View.GetArea <CartesianArea>(); double result; if (area != null && ((area.Orientation == Orientation.Vertical && axis.AxisType == Telerik.Charting.AxisType.First) || (area.Orientation == Orientation.Horizontal && axis.AxisType == Telerik.Charting.AxisType.Second))) { result = view.PlotOriginX + axis.Model.LayoutSlot.X + normalizedValue * (axis.Model.LayoutSlot.Width * view.ZoomWidth); } else { result = view.PlotOriginY + ((ChartView)view).Margin.Top + axis.Model.LayoutSlot.Y + (1.0d - normalizedValue) * (axis.Model.LayoutSlot.Height * view.ZoomHeight); } return(result); }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); RadPoint point1, point2; double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; if (this.axis.type == AxisType.First) { point1 = new RadPoint(panOffsetX + this.plotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY); point2 = new RadPoint(point1.X, plotAreaVirtualSize.Bottom + panOffsetY); } else { point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.plotInfo.CenterY(plotAreaVirtualSize)); point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, point1.Y); } this.line = new RadLine(point1, point2); this.originalLayoutSlot = new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2)); this.line = AnnotationHelper.ClipGridLine(this.line, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness); this.line = RadLine.Round(this.line); return(new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2))); }
private void Chart_DataPointerDown( IChartView chart, IEnumerable <ChartPoint> points) { // notice in the chart event we are not able to use strongly typed points // but we can cast the point.Context.DataSource to the actual type. foreach (var point in points) { if (point.Context.DataSource is City city) { Trace.WriteLine($"[chart.dataPointerDownEvent] clicked on {city.Name}"); continue; } if (point.Context.DataSource is int integer) { Trace.WriteLine($"[chart.dataPointerDownEvent] clicked on number {integer}"); continue; } // handle more possible types here... // if (point.Context.DataSource is Foo foo) // { // ... // } } }
public void Clear(IChartView chart) { chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); TextBlock = null; Line = null; }
public bool Tap(CGPoint tapContentLocation, IChartView chartView, IPointDataSource pointDataSource, IPointHighlightHandler highlightHandler, IXAxis xAxis, IYAxis yAxis) { double sourcePositionStart = xAxis.GetSourceValue(tapContentLocation.X - TapDistance); var sourcePositionEnd = xAxis.GetSourceValue(tapContentLocation.X + TapDistance); var entriesInTapRange = pointDataSource .GetEntriesInRange(sourcePositionStart, sourcePositionEnd) .Select((IPointEntry entry) => new { Entry = entry, Distance = GetDistance(tapContentLocation, entry, xAxis, yAxis) }) .Where((t) => t.Distance <= TapDistance) .OrderBy(p => p.Distance); var entryNearestToTap = entriesInTapRange.FirstOrDefault(); if (entryNearestToTap != null) { highlightHandler.TapOnEntries(Multiselect ? entriesInTapRange.Select(t => t.Entry) : new List <IPointEntry> { entryNearestToTap.Entry }); } else { highlightHandler.TapOnNoEntry(); } return(entryNearestToTap != null); }
/// <summary> /// Constructs a chart. /// </summary> /// <param name="chart">The chart.</param> public void ApplyStyleToChart(IChartView <TDrawingContext> chart) { foreach (var rule in ChartBuilder) { rule(chart); } }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); RadPoint point1, point2; double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; if (this.axis.type == AxisType.First) { point1 = new RadPoint(panOffsetX + this.firstPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY); point2 = new RadPoint(panOffsetX + this.secondPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Bottom + panOffsetY); } else { point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.firstPlotInfo.CenterY(plotAreaVirtualSize)); point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, panOffsetY + this.secondPlotInfo.CenterY(plotAreaVirtualSize)); } var arrangeRect = new RadRect(point1, point2); this.originalLayoutSlot = arrangeRect; return(AnnotationHelper.ClipRectangle(arrangeRect, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness)); }
private async void newChartToolStripMenuItem_Click(object sender, EventArgs e) { using (var dialogBox = new NewChartDialog()) { var result = dialogBox.ShowDialog(); if (result == DialogResult.OK) { string symbol = (string)dialogBox.comboBox_symbols.SelectedItem; Instrument instrument = new Instrument { Name = symbol, Type = InstrumentType.Forex }; TimeFrame timeFrame = (TimeFrame)Enum.Parse(typeof(TimeFrame), dialogBox.comboBox_timeFrame.SelectedItem.ToString()); int size = Convert.ToInt16(dialogBox.textBox_timeFrame_size.Text); var res = new Resolution(timeFrame, size); var fromDate = dialogBox.dateTimePicker_from.Value; var toDate = dialogBox.dateTimePicker_to.Value; var barList = await getHistoricalDataAsync(instrument, res, fromDate, toDate); IChartView chartForm = createChartForm(); chartForm.Resolution = res; chartForm.FromDateTime = fromDate; chartForm.ToDateTime = toDate; //chartForm.SetTitle(); //chartForm.Show(); } } }
public ChartCore(IChartView <TDrawingContext> view, Canvas <TDrawingContext> canvas) { naturalGeometriesCanvas = canvas; chartView = view; updateThrottler = new ActionThrottler(TimeSpan.FromSeconds(300)); updateThrottler.Unlocked += UpdateThrottlerUnlocked; }
private void StockSeries_ChartPointPointerDown( IChartView chart, ChartPoint <Fruit, StepPoint <CircleGeometry>, LabelGeometry> point) { Trace.WriteLine( $"[stock ChartPointPointerDown] clicked on {point.Model.Name}, current stock {point.Model.Stock}"); }
/// <summary> /// Constructs a chart. /// </summary> /// <param name="chart">The chart.</param> public void ApplyStyleToChart(IChartView <TDrawingContext> chart) { if (ChartBuilder == null) { return; } ChartBuilder(chart); }
/// <summary> /// Initializes a new instance of the <see cref="ChartCore"/> class. /// </summary> /// <param name="view">The view.</param> /// <param name="updater">The updater.</param> protected ChartCore(IChartView view, ChartUpdater updater) { View = view; Updater = updater; DrawMargin = new CoreRectangle(); DrawMargin.SetHeight += view.SetDrawMarginHeight; DrawMargin.SetWidth += view.SetDrawMarginWidth; DrawMargin.SetTop += view.SetDrawMarginTop; DrawMargin.SetLeft += view.SetDrawMarginLeft; }
private void Series_DataPointerDown( IChartView chart, IEnumerable <ChartPoint <City, DoughnutGeometry, LabelGeometry> > points) { // the event passes a collection of the points that were triggered by the pointer down event. foreach (var point in points) { Trace.WriteLine($"[series.dataPointerDownEvent] clicked on {point.Model.Name}"); } }
private void PolarLineSeries_DataPointerDown( IChartView chart, IEnumerable <ChartPoint <City, LiveChartsCore.Drawing.LineBezierVisualPoint <LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext, CircleGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.Segments.CubicBezierSegment, SkiaSharp.SKPath>, LabelGeometry> > points) { // the event passes a collection of the points that were triggered by the pointer down event. foreach (var point in points) { Trace.WriteLine($"[series.dataPointerDownEvent] clicked on {point.Model.Name}"); } }
public void LoadElementTree(IChartView chartView) { if (this.IsTreeLoaded) { return; } this.view = chartView; this.View = chartView; this.Load(this); }
public override void ConstructChart(IChartView <SkiaSharpDrawingContext> chart) { var defaultHoverColor = new SKColor(255, 255, 255, 180); chart.PointStates = new PointStatesDictionary <SkiaSharpDrawingContext> { [LiveCharts.BarSeriesHoverKey] = new StrokeAndFillDrawable <SkiaSharpDrawingContext>(null, new SolidColorPaintTask(defaultHoverColor)), [LiveCharts.LineSeriesHoverKey] = new StrokeAndFillDrawable <SkiaSharpDrawingContext>(null, new SolidColorPaintTask(defaultHoverColor)), [LiveCharts.PieSeriesHoverKey] = new StrokeAndFillDrawable <SkiaSharpDrawingContext>(null, new SolidColorPaintTask(defaultHoverColor)), [LiveCharts.ScatterSeriesHoverKey] = new StrokeAndFillDrawable <SkiaSharpDrawingContext>(null, new SolidColorPaintTask(defaultHoverColor)), [LiveCharts.StackedBarSeriesHoverKey] = new StrokeAndFillDrawable <SkiaSharpDrawingContext>(null, new SolidColorPaintTask(defaultHoverColor)), }; }
public IndicatorView(Guid id, string name, IChartView chart, IIndicator indicator) : base(id, m4x4.Identity, name) { Indicator = indicator; Instrument = chart.Instrument; if (chart is CandleChart candle_chart) { Chart = candle_chart.Chart; } Visible = indicator.Visible; PropertyChanged += HandlePropertyChanged; }
protected override IEnumerable <Point> GetPoints(DataPointSegment segment) { // return the first point since spline segmentation skips it yield return(this.renderPoints[segment.StartIndex].Center()); IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor)) { yield return(point); } }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; RadPoint centerPoint = new RadPoint(panOffsetX + this.firstPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.secondPlotInfo.CenterY(plotAreaVirtualSize)); RadSize desiredSize = this.Measure(); return(new RadRect(centerPoint.X, centerPoint.Y, desiredSize.Width, desiredSize.Height)); }
private void UnanimatedPlace(IChartView chart, AxisTags direction, int axisIndex, Axis axis) { var i = ChartFunctions.ToPlotArea(Model.Value, direction, chart.Model, axisIndex); var uw = new CorePoint( axis.Model.EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(AxisTags.X, chart.Model, axis.Model) / 2 : 0, axis.Model.EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(AxisTags.Y, chart.Model, axis.Model) / 2 : 0); if (direction == AxisTags.Y) { Line.X1 = chart.Model.DrawMargin.Left; Line.X2 = chart.Model.DrawMargin.Left + chart.Model.DrawMargin.Width; Line.Y1 = i; Line.Y2 = i; var topM = axis.IsMerged ? (i + TextBlock.ActualHeight > chart.Model.DrawMargin.Top + chart.Model.DrawMargin.Height ? +TextBlock.ActualHeight : 0) : TextBlock.ActualHeight * .5; var leftM = axis.IsMerged ? TextBlock.ActualWidth + 10 : -2; Canvas.SetTop(TextBlock, i + uw.Y - topM); Canvas.SetLeft(TextBlock, axis.Position == AxisPosition.LeftBottom ? axis.LabelsReference - TextBlock.ActualWidth + leftM : axis.LabelsReference - leftM); } else { Line.X1 = i; Line.X2 = i; Line.Y1 = chart.Model.DrawMargin.Top; Line.Y2 = chart.Model.DrawMargin.Top + chart.Model.DrawMargin.Height; var left = axis.IsMerged ? (i + TextBlock.ActualWidth > chart.Model.DrawMargin.Left + chart.Model.DrawMargin.Width ? TextBlock.ActualWidth + 2 : -2) : TextBlock.ActualWidth * .5; var top = axis.IsMerged ? TextBlock.ActualHeight : 0; Canvas.SetLeft(TextBlock, i + uw.X - left); Canvas.SetTop(TextBlock, axis.Position == AxisPosition.LeftBottom ? axis.LabelsReference - top : axis.LabelsReference); } }
protected virtual void DefaultOnPointCreated(TVisual visual, IChartView <TDrawingContext> chart) { visual .TransitionateProperties(nameof(visual.X), nameof(visual.Width)) .WithAnimation(animation => animation .WithDuration(chart.AnimationsSpeed) .WithEasingFunction(chart.EasingFunction)); visual .TransitionateProperties(nameof(visual.Y), nameof(visual.Height)) .WithAnimation(animation => animation .WithDuration(chart.AnimationsSpeed) .WithEasingFunction(EasingFunctions.ElasticOut)); }
public void Clear(IChartView chart) { #if DEBUG Debug.WriteLine(((Canvas)chart.GetCanvas()).Children.Count); #endif chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); #if DEBUG Debug.WriteLine(((Canvas) chart.GetCanvas()).Children.Count); #endif TextBlock = null; Line = null; }
public void Clear(IChartView chart) { #if DEBUG Debug.WriteLine(((Canvas)chart.GetCanvas()).Children.Count); #endif chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); #if DEBUG Debug.WriteLine(((Canvas)chart.GetCanvas()).Children.Count); #endif TextBlock = null; Line = null; }
private void FadeIn(IChartView chart, Axis axis) { if (axis.DisableAnimations || chart.DisableAnimations) { return; } if (TextBlock.Visibility != Visibility.Collapsed) { TextBlock.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(0, 1, chart.AnimationsSpeed)); } if (Line.Visibility != Visibility.Collapsed) { Line.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(1000))); } }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; RadPoint point1 = new RadPoint(panOffsetX + this.horizontalFromPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalFromPlotInfo.CenterY(plotAreaVirtualSize)); RadPoint point2 = new RadPoint(panOffsetX + this.horizontalToPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalToPlotInfo.CenterY(plotAreaVirtualSize)); var arrangeRect = new RadRect(point1, point2); this.originalLayoutSlot = arrangeRect; return(AnnotationHelper.ClipRectangle(arrangeRect, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness)); }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; RadPoint point1 = new RadPoint(panOffsetX + this.horizontalFromPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalFromPlotInfo.CenterY(plotAreaVirtualSize)); RadPoint point2 = new RadPoint(panOffsetX + this.horizontalToPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalToPlotInfo.CenterY(plotAreaVirtualSize)); this.line = new RadLine(point1, point2); this.originalLayoutSlot = new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2)); this.line = AnnotationHelper.ClipLine(this.line, rect, 2 * this.StrokeThickness, this.DashPatternLength * this.StrokeThickness); this.line = RadLine.Round(this.line); return(new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2))); }
private void addNewChartFormToRightPanel(Resolution resolution, DateTime fromDateTime, DateTime toDateTime) { IChartView chartForm = this.createChartForm(); //chartForm.Dock = DockStyle.Fill; chartForm.Resolution = resolution; chartForm.FromDateTime = fromDateTime; chartForm.ToDateTime = toDateTime; //chartForm.SetTitle(); //c.FormBorderStyle = FormBorderStyle.None; //chart.DoubleClick += chart_MouseDoubleClick; //chartForm.FormClosing += (sender, e) => //{ // if (e.CloseReason == CloseReason.UserClosing) // { // e.Cancel = true; // return; // } //}; var tpl = tableLayoutPanel_chartForm; int count = tpl.Controls.Count; int column = count % 2 == 0 ? count / 2 : (count - 1) / 2; int row = count % 2; if (column > tableLayoutPanel_chartForm.ColumnCount) { tableLayoutPanel_chartForm.ColumnCount = column; //tpl.ColumnStyles.Add(new ColumnStyle { SizeType = SizeType.Percent, Width = 100 / (tpl.ColumnCount+2) }); } if (row > tableLayoutPanel_chartForm.RowCount) { tableLayoutPanel_chartForm.RowCount = row; //tpl.RowStyles.Add(new RowStyle { SizeType = SizeType.Percent, Height = 100 / (tpl.RowCount+2) }); } tableLayoutPanel_chartForm.Controls.Add((Control)chartForm, column, row); }
private void Remove(IChartView chart, Axis axis) { if (axis.DisableAnimations || chart.DisableAnimations) { chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); return; } if (TextBlock.Visibility == Visibility.Collapsed && Line.Visibility == Visibility.Collapsed) { return; } var anim = new DoubleAnimation { From = 1, To = 0, Duration = chart.AnimationsSpeed }; anim.Completed += (sender, args) => { if (Application.Current == null) { chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); return; } Application.Current.Dispatcher.Invoke(new Action(() => { chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); })); }; TextBlock.BeginAnimation(UIElement.OpacityProperty, anim); Line.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1, 0, chart.AnimationsSpeed)); }
public PieChartCore(IChartView view, IChartUpdater updater) : base(view, updater) { updater.Chart = this; }
/// <summary> /// Clears the specified chart. /// </summary> /// <param name="chart">The chart.</param> public void Clear(IChartView chart) { chart.RemoveFromView(TextBlock); chart.RemoveFromView(Line); TextBlock = null; Line = null; }
/// <summary> /// Initializes Chart model /// </summary> /// <param name="view">The view.</param> /// <param name="updater">The updater.</param> public CartesianChartCore(IChartView view, ChartUpdater updater) : base(view, updater) { updater.Chart = this; }