예제 #1
0
        private void LineMarker_PositionChanged(object sender, C1.WPF.Chart.Interaction.PositionChangedArgs e)
        {
            var chartPoint   = new Point(LineMarker.X, LineMarker.Y);
            var _hitTestInfo = MainChart.HitTest(chartPoint);

            var hitTestInfo = MainChart.HitTest(chartPoint);
        }
예제 #2
0
        private void OnLineMarkerPositionChanged(object sender, C1.WPF.Chart.Interaction.PositionChangedArgs e)
        {
            if (financialChart1 != null)
            {
                var info  = financialChart1.HitTest(new Point(e.Position.X, e.Position.Y));
                var value = lineMarker.Y; // financialChart1.AxisY.Min + (financialChart1.AxisY.Max - financialChart1.AxisY.Min) * (financialChart1.PlotRect.Top + financialChart1.PlotRect.Height - lineMarker.Y) / financialChart1.PlotRect.Height;

                //draw Y rectangle

                var format = string.Format((value >= 0 ? "+{0:P2}" : "{0:P2}"), value);
                if (value == 0)
                {
                    format = "{0:P2}";
                }
                var text = string.Format(ViewModel.ChartViewModel.Instance.IsComparisonMode ? format : "{0:.##}", value);

                var tb = new TextBlock();
                tb.Padding    = new Thickness(10);
                tb.Background = new SolidColorBrush(Color.FromArgb(255, 34, 34, 34));

                tb.Inlines.Add(new Run()
                {
                    Text       = string.Format("{0:MMM dd, yyyy} \r\n", info.X),
                    Foreground = new SolidColorBrush()
                    {
                        Color = Color.FromArgb(255, 170, 170, 170)
                    },
                });

                tb.Inlines.Add(new Run()
                {
                    Text       = text,
                    Foreground = new SolidColorBrush()
                    {
                        Color = Color.FromArgb(255, 170, 170, 170)
                    },
                    FontWeight = FontWeights.Bold
                });
                lineMarker.Content = tb;
            }
        }