private void Chart_OnDataClick(object sender, ChartPoint point)
        {
            //point instance contains many useful information...
            //sender is the shape that called the event.

            MessageBox.Show("You clicked " + point.X + ", " + point.Y);
        }
Beispiel #2
0
 private async void ChartOnDataClick(object sender, ChartPoint chartPoint)
 {
     var asPixels = this.Chart.ConvertToPixels(chartPoint.AsPoint());
     var dialog = new MessageDialog("You clicked (" + chartPoint.X + ", " + chartPoint.Y + ") in pixels (" +
                     asPixels.X + ", " + asPixels.Y + ")");
     await dialog.ShowAsync();
 }
Beispiel #3
0
        private void ChartOnDataClick(object sender, LiveCharts.ChartPoint p)
        {
            var asPixels = cartesianChart1.Base.ConvertToPixels(p.AsPoint());

            richTextBox1.SelectionColor = Color.AliceBlue;
            richTextBox1.Text          += "[EVENT] You clicked(" + p.X + ", " + p.Y + ") in pixels(" +
                                          asPixels.X + ", " + asPixels.Y + ")";
        }
Beispiel #4
0
        private async void Chart_OnDataClick(object sender, ChartPoint point)
        {
            //point instance contains many useful information...
            //sender is the shape that called the event.
            var dialog = new MessageDialog("You clicked " + point.X + ", " + point.Y);
            await dialog.ShowAsync();


        }
Beispiel #5
0
        private void Chart_OnDataClick(object sender, LiveCharts.ChartPoint chartPoint)
        {
            var chart = (PieChart)chartPoint.ChartView;

            foreach (PieSeries series in chart.Series)
            {
                series.PushOut = 0;
            }

            var selectedSeries = (PieSeries)chartPoint.SeriesView;

            selectedSeries.PushOut = 8;
        }
Beispiel #6
0
        private void PieChart_DataClick(object sender, LiveCharts.ChartPoint chartPoint)
        {
            var chart1 = chartPoint.ChartView as PieChart;

            foreach (PieSeries pie in chart1.Series)
            {
                pie.PushOut = 0;
            }

            var neo = chartPoint.SeriesView as PieSeries;

            neo.PushOut = 30;
        }
Beispiel #7
0
        /// <summary>
        /// Returns data in the chart according to:
        /// </summary>
        /// <param name="senderPoint">point that was hovered</param>
        /// <param name="chart">chart model to get the data from</param>
        /// <param name="selectionMode">selection mode</param>
        /// <returns></returns>
        public static TooltipDataViewModel GetTooltipData(ChartPoint senderPoint, ChartCore chart, TooltipSelectionMode selectionMode)
        {
            var ax = chart.AxisX[senderPoint.SeriesView.ScalesXAt];
            var ay = chart.AxisY[senderPoint.SeriesView.ScalesYAt];

            switch (selectionMode)
            {
            case TooltipSelectionMode.OnlySender:
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = new List <ChartPoint> {
                        senderPoint
                    },
                    Shares = null
                });

            case TooltipSelectionMode.SharedXValues:
                var tx = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                  - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = chart.View.ActualSeries.Where(x => x.ScalesXAt == senderPoint.SeriesView.ScalesXAt)
                             .SelectMany(x => x.Values.GetPoints(x))
                             .Where(x => Math.Abs(x.X - senderPoint.X) < tx),
                    Shares = (chart.View is IPieChart) ? null : (double?)senderPoint.X
                });

            case TooltipSelectionMode.SharedYValues:
                var ty = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                  - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = chart.View.ActualSeries.Where(x => x.ScalesYAt == senderPoint.SeriesView.ScalesYAt)
                             .SelectMany(x => x.Values.GetPoints(x))
                             .Where(x => Math.Abs(x.Y - senderPoint.Y) < ty),
                    Shares = senderPoint.Y
                });

            case TooltipSelectionMode.SharedXInSeries:
                var txs = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                   - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                             .Where(x => Math.Abs(x.X - senderPoint.X) < txs),
                    Shares = senderPoint.X
                });

            case TooltipSelectionMode.SharedYInSeries:
                var tys = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                   - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                return(new TooltipDataViewModel
                {
                    XFormatter = ax.GetFormatter(),
                    YFormatter = ay.GetFormatter(),
                    Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                             .Where(x => Math.Abs(x.Y - senderPoint.Y) < tys),
                    Shares = senderPoint.Y
                });

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #8
0
 private void Pie_Chart_DataClick(object sender, LiveCharts.ChartPoint chartPoint)
 {
 }
Beispiel #9
0
        private VisualHelper GetVisual(ChartPoint point)
        {
            var map = _isPrimitive
                ? Chart.ShapesMapper.FirstOrDefault(x => x.Series.Equals(this) &&
                                                    x.ChartPoint.Key == point.Key)
                : Chart.ShapesMapper.FirstOrDefault(x => x.Series.Equals(this) &&
                                                    x.ChartPoint.Instance == point.Instance);

            if (map == null)
            {
                var r = new Rectangle
                {
                    RenderTransform = new TranslateTransform()
                };
                var hs = new Rectangle
                {
                    Fill            = Brushes.Transparent,
                    StrokeThickness = 0
                };
                BindingOperations.SetBinding(r, Shape.StrokeProperty,
                                             new Binding {
                    Path = new PropertyPath("Stroke"), Source = this
                });
                BindingOperations.SetBinding(r, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath("Fill"), Source = this
                });
                BindingOperations.SetBinding(r, Shape.StrokeThicknessProperty,
                                             new Binding {
                    Path = new PropertyPath("StrokeThickness"), Source = this
                });
                BindingOperations.SetBinding(r, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath("Visibility"), Source = this
                });
                BindingOperations.SetBinding(r, Panel.ZIndexProperty,
                                             new Binding {
                    Path = new PropertyPath(Panel.ZIndexProperty), Source = this
                });
                BindingOperations.SetBinding(r, Shape.StrokeDashArrayProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeDashArrayProperty), Source = this
                });
                BindingOperations.SetBinding(hs, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath("Visibility"), Source = this
                });

                return(new VisualHelper
                {
                    PointShape = r,
                    HoverShape = hs,
                    IsNew = true
                });
            }

            map.ChartPoint.X = point.X;
            map.ChartPoint.Y = point.Y;

            return(new VisualHelper
            {
                PointShape = map.Shape,
                HoverShape = map.HoverShape,
                IsNew = false
            });
        }
Beispiel #10
0
 /// <summary>
 /// Converts from chart values to chart draw margin size.
 /// </summary>
 /// <param name="point">point to scale</param>
 /// <param name="axisXIndex">axis orientation</param>
 /// <param name="axisYIndex">axis instance to scale the value at</param>
 /// <param name="chart">chart model to scale the value at</param>
 /// <returns></returns>
 public static CorePoint ToDrawMargin(ChartPoint point, int axisXIndex, int axisYIndex, ChartCore chart)
 {
     return(new CorePoint(
                ToDrawMargin(point.X, AxisOrientation.X, chart, axisXIndex),
                ToDrawMargin(point.Y, AxisOrientation.Y, chart, axisYIndex)));
 }
        /// <summary>
        /// Evaluates the limits in the chart values
        /// </summary>
        public void Initialize(ISeriesView seriesView)
        {
            var config = GetConfig(seriesView);

            if (config == null)
            {
                return;
            }

            var xMin = double.PositiveInfinity;
            var xMax = double.NegativeInfinity;
            var yMin = double.PositiveInfinity;
            var yMax = double.NegativeInfinity;
            var wMin = double.PositiveInfinity;
            var wMax = double.NegativeInfinity;

            var tracker = GetTracker(seriesView);

            var cp = new ChartPoint();

            var source = this.ToArray();

            var    ax = seriesView.Model.Chart.AxisX[seriesView.ScalesXAt];
            var    ay = seriesView.Model.Chart.AxisY[seriesView.ScalesYAt];
            double fx = double.IsNaN(ax.MinValue) ? double.NegativeInfinity : ax.MinValue,
                   tx = double.IsNaN(ax.MaxValue) ? double.PositiveInfinity : ax.MaxValue,
                   fy = double.IsNaN(ay.MinValue) ? double.NegativeInfinity : ay.MinValue,
                   ty = double.IsNaN(ay.MaxValue) ? double.PositiveInfinity : ay.MaxValue;

            var isHorizontal = seriesView.Model.SeriesOrientation == SeriesOrientation.Horizontal;

            for (var index = 0; index < source.Length; index++)
            {
                var item = source[index];
                config.Evaluate(index, item, cp);

                if (isHorizontal)
                {
                    if (cp.X < fx || cp.X > tx)
                    {
                        continue;
                    }
                }
                else
                {
                    if (cp.Y < fy || cp.Y > ty)
                    {
                        continue;
                    }
                }

                if (seriesView is IFinancialSeriesView)
                {
                    if (cp.X < xMin)
                    {
                        xMin = cp.X;
                    }
                    if (cp.X > xMax)
                    {
                        xMax = cp.X;
                    }

                    if (cp.Low < yMin)
                    {
                        yMin = cp.Low;
                    }
                    if (cp.High > yMax)
                    {
                        yMax = cp.High;
                    }

                    if (cp.Weight < wMin)
                    {
                        wMin = cp.Weight;
                    }
                    if (cp.Weight > wMax)
                    {
                        wMax = cp.Weight;
                    }
                }
                else if (seriesView is IScatterSeriesView || seriesView is IHeatSeriesView)
                {
                    if (cp.X < xMin)
                    {
                        xMin = cp.X;
                    }
                    if (cp.X > xMax)
                    {
                        xMax = cp.X;
                    }

                    if (cp.Y < yMin)
                    {
                        yMin = cp.Y;
                    }
                    if (cp.Y > yMax)
                    {
                        yMax = cp.Y;
                    }

                    if (cp.Weight < wMin)
                    {
                        wMin = cp.Weight;
                    }
                    if (cp.Weight > wMax)
                    {
                        wMax = cp.Weight;
                    }
                }
                else
                {
                    if (cp.X < xMin)
                    {
                        xMin = cp.X;
                    }
                    if (cp.X > xMax)
                    {
                        xMax = cp.X;
                    }

                    if (cp.Y < yMin)
                    {
                        yMin = cp.Y;
                    }
                    if (cp.Y > yMax)
                    {
                        yMax = cp.Y;
                    }
                }
            }

            tracker.XLimit = new CoreLimit(double.IsInfinity(xMin)
                ? 0
                : xMin, double.IsInfinity(yMin) ? 1 : xMax);
            tracker.YLimit = new CoreLimit(double.IsInfinity(yMin)
                ? 0
                : yMin, double.IsInfinity(yMax) ? 1 : yMax);
            tracker.WLimit = new CoreLimit(double.IsInfinity(wMin)
                ? 0
                : wMin, double.IsInfinity(wMax) ? 1 : wMax);
        }
        /// <summary>
        /// Returns data in the chart according to:
        /// </summary>
        /// <param name="senderPoint">point that was hovered</param>
        /// <param name="chart">chart model to get the data from</param>
        /// <param name="selectionMode">selection mode</param>
        /// <returns></returns>
        public static TooltipDataViewModel GetTooltipData(ChartPoint senderPoint, ChartCore chart, TooltipSelectionMode selectionMode)
        {
            var ax = chart.AxisX[senderPoint.SeriesView.ScalesXAt];
            var ay = chart.AxisY[senderPoint.SeriesView.ScalesYAt];

            switch (selectionMode)
            {
                case TooltipSelectionMode.OnlySender:
                    return new TooltipDataViewModel
                    {
                        XFormatter = ax.GetFormatter(),
                        YFormatter = ay.GetFormatter(),
                        Points = new List<ChartPoint> {senderPoint},
                        Shares = null
                    };
                case TooltipSelectionMode.SharedXValues:
                    var tx = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                      - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                    return new TooltipDataViewModel
                    {
                        XFormatter = ax.GetFormatter(),
                        YFormatter = ay.GetFormatter(),
                        Points = chart.View.ActualSeries.Where(x => x.ScalesXAt == senderPoint.SeriesView.ScalesXAt)
                            .SelectMany(x => x.Values.GetPoints(x))
                            .Where(x => Math.Abs(x.X - senderPoint.X) < tx),
                        Shares = (chart.View is IPieChart) ? null : (double?) senderPoint.X
                    };
                case TooltipSelectionMode.SharedYValues:
                    var ty = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                     - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                    return new TooltipDataViewModel
                    {
                        XFormatter = ax.GetFormatter(),
                        YFormatter = ay.GetFormatter(),
                        Points = chart.View.ActualSeries.Where(x => x.ScalesYAt == senderPoint.SeriesView.ScalesYAt)
                            .SelectMany(x => x.Values.GetPoints(x))
                            .Where(x => Math.Abs(x.Y - senderPoint.Y) < ty),
                        Shares = senderPoint.Y
                    };
                case TooltipSelectionMode.SharedXInSeries:
                    var txs = Math.Abs(FromPlotArea(1, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)
                                     - FromPlotArea(2, AxisOrientation.X, chart, senderPoint.SeriesView.ScalesXAt)) * .01;
                    return new TooltipDataViewModel
                    {
                        XFormatter = ax.GetFormatter(),
                        YFormatter = ay.GetFormatter(),
                        Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                            .Where(x => Math.Abs(x.X - senderPoint.X) < txs),
                        Shares = senderPoint.X
                    };
                case TooltipSelectionMode.SharedYInSeries:
                    var tys = Math.Abs(FromPlotArea(1, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)
                                     - FromPlotArea(2, AxisOrientation.Y, chart, senderPoint.SeriesView.ScalesYAt)) * .01;
                    return new TooltipDataViewModel
                    {
                        XFormatter = ax.GetFormatter(),
                        YFormatter = ay.GetFormatter(),
                        Points = senderPoint.SeriesView.ActualValues.GetPoints(senderPoint.SeriesView)
                            .Where(x => Math.Abs(x.Y - senderPoint.Y) < tys),
                        Shares = senderPoint.Y
                    };
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #13
0
        private VisualHelper GetVisual(ChartPoint point)
        {
            var map = _isPrimitive
                ? Chart.ShapesMapper.FirstOrDefault(x => x.Series.Equals(this) &&
                                                    x.ChartPoint.Key == point.Key)
                : Chart.ShapesMapper.FirstOrDefault(x => x.Series.Equals(this) &&
                                                    x.ChartPoint.Instance == point.Instance);

            var pChart = Chart as PieChart;

            if (pChart == null)
            {
                throw new InvalidCastException("Unexpected error converting chart to pie chart.");
            }

            if (map == null)
            {
                var newSlice = new PieSlice
                {
                    CentreX = 0,
                    CentreY = 0
                };

                BindingOperations.SetBinding(newSlice, Shape.StrokeProperty,
                                             new Binding {
                    Path = new PropertyPath("Stroke"), Source = this
                });
                BindingOperations.SetBinding(newSlice, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath("Fill"), Source = this
                });
                BindingOperations.SetBinding(newSlice, Shape.StrokeThicknessProperty,
                                             new Binding {
                    Path = new PropertyPath("StrokeThickness"), Source = this
                });
                BindingOperations.SetBinding(newSlice, Shape.StrokeDashArrayProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeDashArrayProperty), Source = this
                });
                BindingOperations.SetBinding(newSlice, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath("Visibility"), Source = this
                });

                return(new VisualHelper
                {
                    HoverShape = newSlice,
                    PointShape = newSlice,
                    IsNew = true
                });
            }

            map.ChartPoint.X = point.X;
            map.ChartPoint.Y = point.Y;

            return(new VisualHelper
            {
                PointShape = (PieSlice)map.Shape,
                HoverShape = (PieSlice)map.HoverShape,
                IsNew = false
            });
        }
Beispiel #14
0
        private VisualPoint GetShapes(ChartPoint point, PathFigure pathFigure)
        {
            VisualPoint trackable;

            if (IsPrimitive)
            {
                if (Tracker.Primitives.TryGetValue(point.Key, out trackable))
                {
                    trackable.IsNew = false;
                    return(trackable);
                }
            }
            else
            {
                if (Tracker.Instances.TryGetValue(point.Instance, out trackable))
                {
                    trackable.IsNew = false;
                    return(trackable);
                }
            }

            Ellipse   e  = null;
            Rectangle hs = null;
            TextBlock tb = null;

            if (RequeriesDataPoint)
            {
                e = new Ellipse
                {
                    Width  = PointRadius * 2,
                    Height = PointRadius * 2,
                    Stroke = new SolidColorBrush {
                        Color = Chart.PointHoverColor
                    },
                    StrokeThickness = 1
                };
                BindingOperations.SetBinding(e, Shape.FillProperty,
                                             new Binding {
                    Path = new PropertyPath(StrokeProperty), Source = this
                });
                BindingOperations.SetBinding(e, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath(VisibilityProperty), Source = this
                });
            }

            if (Chart.Hoverable)
            {
                hs = new Rectangle
                {
                    Fill            = Brushes.Transparent,
                    StrokeThickness = 0
                };
                BindingOperations.SetBinding(hs, VisibilityProperty,
                                             new Binding {
                    Path = new PropertyPath(VisibilityProperty), Source = this
                });
            }

            if (DataLabels)
            {
                tb = BindATextBlock(0);
            }

            trackable = new LineVisualPoint(pathFigure)
            {
                IsNew      = true,
                HoverShape = hs,
                Shape      = e,
                TextBlock  = tb,
                Segment    = new BezierSegment()
            };

            if (IsPrimitive)
            {
                Tracker.Primitives[point.Key] = trackable;
            }
            else
            {
                Tracker.Instances[point.Instance] = trackable;
            }

            return(trackable);

            //Todo: If Hoverable property changes this could throw a null exception,
            //When Hoverable property changes, we need to load the shapes again.
            //or delete then if false, to improve performance.

            //map.ChartPoint.X = point.X; ToDo This might break something!!!
            //map.ChartPoint.Y = point.Y;
            //return new VisualHelper
            //{
            //    PointShape = map.Shape,
            //    HoverShape = map.HoverShape,
            //    IsNew = false
            //};
        }
Beispiel #15
0
        private void PlaceShapes(LineVisualPoint lineVisualPoint, ChartPoint chartPoint, double radius, Func <double, string> f)
        {
            if (lineVisualPoint.HoverShape != null)
            {
                lineVisualPoint.HoverShape.Width  = radius * 2;
                lineVisualPoint.HoverShape.Height = radius * 2;
                Canvas.SetLeft(lineVisualPoint.HoverShape, chartPoint.Location.X - lineVisualPoint.HoverShape.Width * .5);
                Canvas.SetTop(lineVisualPoint.HoverShape, chartPoint.Location.Y - lineVisualPoint.HoverShape.Height * .5);

                if (lineVisualPoint.IsNew)
                {
                    Chart.DrawMargin.Children.Add(lineVisualPoint.HoverShape);
                    Panel.SetZIndex(lineVisualPoint.HoverShape, int.MaxValue);
                    lineVisualPoint.HoverShape.MouseDown  += Chart.DataMouseDown;
                    lineVisualPoint.HoverShape.MouseEnter += Chart.DataMouseEnter;
                    lineVisualPoint.HoverShape.MouseLeave += Chart.DataMouseLeave;
                }
            }

            if (lineVisualPoint.Shape != null)
            {
                if (lineVisualPoint.IsNew)
                {
                    Panel.SetZIndex(lineVisualPoint.Shape, int.MaxValue - 2);
                    if (Chart.Invert)
                    {
                        Canvas.SetLeft(lineVisualPoint.Shape, 0d);
                        Canvas.SetTop(lineVisualPoint.Shape, chartPoint.Location.Y - lineVisualPoint.Shape.Height * .5);
                    }
                    else
                    {
                        Canvas.SetLeft(lineVisualPoint.Shape, chartPoint.Location.X - lineVisualPoint.Shape.Width * .5);
                        Canvas.SetTop(lineVisualPoint.Shape, Chart.DrawMargin.Height);
                    }
                    Chart.DrawMargin.Children.Add(lineVisualPoint.Shape);
                }
                if (Chart.DisableAnimations)
                {
                    Canvas.SetTop(lineVisualPoint.Shape, chartPoint.Location.Y - lineVisualPoint.Shape.Height * .5);
                    Canvas.SetLeft(lineVisualPoint.Shape, chartPoint.Location.X - lineVisualPoint.Shape.Width * .5);
                }
                else
                {
                    lineVisualPoint.Shape.BeginAnimation(Canvas.LeftProperty,
                                                         new DoubleAnimation(chartPoint.Location.X - lineVisualPoint.Shape.Width * .5, _animSpeed));
                    lineVisualPoint.Shape.BeginAnimation(Canvas.TopProperty,
                                                         new DoubleAnimation(chartPoint.Location.Y - lineVisualPoint.Shape.Height * .5, _animSpeed));
                }
            }

            if (lineVisualPoint.TextBlock != null)
            {
                var te = f(Chart.Invert ? chartPoint.X : chartPoint.Y);

                lineVisualPoint.TextBlock.Text = te;
                lineVisualPoint.TextBlock.UpdateLayout();
                lineVisualPoint.TextBlock.Measure(new Size(double.MaxValue, double.MaxValue));
                var ft = lineVisualPoint.TextBlock.DesiredSize;

                var length = chartPoint.Location.X - ft.Width * .5;
                length = length < 0
                    ? 0
                    : (length + ft.Width > Chart.DrawMargin.Width
                        ? Chart.DrawMargin.Width - ft.Width
                        : length);
                var tp = chartPoint.Location.Y - ft.Height - 5;
                tp = tp < 0 ? 0 : tp;

                if (lineVisualPoint.IsNew)
                {
                    Chart.DrawMargin.Children.Add(lineVisualPoint.TextBlock);
                    Panel.SetZIndex(lineVisualPoint.TextBlock, int.MaxValue - 2);

                    if (Chart.Invert)
                    {
                        Canvas.SetLeft(lineVisualPoint.TextBlock, 0d);
                        Canvas.SetTop(lineVisualPoint.TextBlock, tp);
                    }
                    else
                    {
                        Canvas.SetLeft(lineVisualPoint.TextBlock, length);
                        Canvas.SetTop(lineVisualPoint.TextBlock, Chart.DrawMargin.Height);
                    }
                }

                if (Chart.DisableAnimations)
                {
                    Canvas.SetTop(lineVisualPoint.TextBlock, tp);
                    Canvas.SetLeft(lineVisualPoint.TextBlock, length);
                }
                else
                {
                    lineVisualPoint.TextBlock.BeginAnimation(Canvas.TopProperty,
                                                             new DoubleAnimation(tp, _animSpeed));
                    lineVisualPoint.TextBlock.BeginAnimation(Canvas.LeftProperty,
                                                             new DoubleAnimation(length, _animSpeed));
                }
            }
        }
Beispiel #16
0
 internal static Point AsPoint(this ChartPoint chartPoint)
 {
     return(new Point(chartPoint.X, chartPoint.Y));
 }
Beispiel #17
0
 private void Chart_OnDataHover(object sender, LiveCharts.ChartPoint chartPoint)
 {
     richTextBox1.SelectionColor = Color.LightGreen;
     richTextBox1.Text          += "on data Hover \r\n";
 }
Beispiel #18
0
        private void MainChart_DataClick(object sender, LiveCharts.ChartPoint chartPoint)
        {
            int pointX = (int)chartPoint.X;

            ((IPageViewModel)DataContext).CurrentRow = pointX;
        }
Beispiel #19
0
        private IEnumerable <ChartPoint> Iterate()
        {
            if (Series == null)
            {
                yield break;
            }

            var config = GetConfig();

            var isClass      = typeof(T).IsClass;
            var isObservable = isClass &&
                               typeof(IObservableChartPoint).IsAssignableFrom(typeof(T));

            var garbageCollectorIndex = GarbageCollectorIndex;
            var i = 0;

            foreach (var value in this)
            {
                if (isObservable)
                {
                    var observable = (IObservableChartPoint)value;
                    if (observable != null)
                    {
                        observable.PointChanged -= ObservableOnPointChanged;
                        observable.PointChanged += ObservableOnPointChanged;
                    }
                }

                ChartPoint cp;

                if (!isClass)
                {
                    if (!IndexedDictionary.TryGetValue(i, out cp))
                    {
                        cp = new ChartPoint
                        {
                            Instance = value,
                            Key      = i
                        };
                        IndexedDictionary[i] = cp;
                    }
                }
                else
                {
                    if (!ClassesDictionary.TryGetValue(value, out cp))
                    {
                        cp = new ChartPoint
                        {
                            Instance = value,
                            Key      = i
                        };
                        ClassesDictionary[value] = cp;
                    }
                }

                cp.GarbageCollectorIndex = garbageCollectorIndex;

                cp.Instance = value;
                cp.Key      = i;

                config.SetAll(new KeyValuePair <int, T>(i, value), cp);
                //ToDo: this feels bad, when indexing the data, this is already done...
                //Also the index will break every run...

                yield return(cp);

                i++;
            }
        }
Beispiel #20
0
 private bool IsGarbage(ChartPoint point)
 {
     return(point.GarbageCollectorIndex < GarbageCollectorIndex ||
            double.IsNaN(point.X) || double.IsNaN(point.Y));
 }
 private static bool IsGarbage(ChartPoint point, PointTracker tracker)
 {
     return(point.Gci < tracker.Gci ||
            double.IsNaN(point.X) || double.IsNaN(point.Y));
 }
 private void ChartOnDataClick(object sender, ChartPoint chartPoint)
 {
     var asPixels = Chart.ConvertToPixels(chartPoint.AsPoint());
     MessageBox.Show("You clicked (" + chartPoint.X + ", " + chartPoint.Y + ") in pixels (" +
                     asPixels.X + ", " + asPixels.Y + ")");
 }
 /// <summary>
 /// Converts from chart values to chart draw margin size.
 /// </summary>
 /// <param name="point">point to scale</param>
 /// <param name="axisXIndex">axis orientation</param>
 /// <param name="axisYIndex">axis instance to scale the value at</param>
 /// <param name="chart">chart model to scale the value at</param>
 /// <returns></returns>
 public static CorePoint ToDrawMargin(ChartPoint point, int axisXIndex, int axisYIndex, ChartCore chart)
 {
     return new CorePoint(
         ToDrawMargin(point.X, AxisOrientation.X, chart, axisXIndex),
         ToDrawMargin(point.Y, AxisOrientation.Y, chart, axisYIndex));
 }