Пример #1
0
        void chaLine_MouseMove(object sender, MouseEventArgs e)
        {
            ValueOverlay chaLine = sender as ValueOverlay;
            var          series  = dataChart.Series.FirstOrDefault();

            if (series == null)
            {
                return;
            }

            var position = e.GetPosition(series);

            if (((XamDataChart)series.SeriesViewer).Axes.OfType <NumericXAxis>().Any())
            {
                var xAxis = ((XamDataChart)series.SeriesViewer).Axes.OfType <NumericXAxis>().First();
                var yAxis = ((XamDataChart)series.SeriesViewer).Axes.OfType <NumericYAxis>().First();

                var viewport = new Rect(0, 0, xAxis.ActualWidth, yAxis.ActualHeight);
                var window   = series.SeriesViewer.WindowRect;

                bool         isInverted = xAxis.IsInverted;
                ScalerParams param      = new ScalerParams(window, viewport, isInverted);
                var          unscaledX  = xAxis.GetUnscaledValue(position.X, param);
                foreach (YuMiBaoZiModel data in predictModels)
                {
                    Int16 x = Convert.ToInt16(data.xData);
                    if (Convert.ToInt16(unscaledX) == x)
                    {
                        block.Text = data.predictChaValue.ToString();
                    }
                }
                chaLine.Value = unscaledX;
            }
        }
Пример #2
0
        private void initTimeBar(double timeClip)
        {
            ValueOverlay timeLine = new ValueOverlay();

            timeLine.Axis      = (NumericXAxis)dataChart.Axes[2];
            timeLine.Brush     = new SolidColorBrush(Colors.Red);
            timeLine.Thickness = 10;
            timeLine.Opacity   = 0.5;
            timeLine.Value     = timeClip;
            TextBlock textBlock = new TextBlock();

            textBlock.Text      = "预测时间轴";
            timeLine.ToolTip    = textBlock;
            timeLine.Visibility = Visibility.Visible;
            dataChart.Series.Add(timeLine);
        }
Пример #3
0
        private void initMoveTimeBar(double timeClip)
        {
            ValueOverlay chaLine = new ValueOverlay();

            chaLine.Axis      = (NumericXAxis)dataChart.Axes[2];
            chaLine.Brush     = new SolidColorBrush(Colors.Blue);
            chaLine.Thickness = 10;
            chaLine.Opacity   = 0.5;
            chaLine.Value     = timeClip;

            chaLine.MouseEnter += chaLine_MouseEnter;
            chaLine.MouseMove  += chaLine_MouseMove;
            Grid       grid      = new Grid();
            StackPanel stackVer  = new StackPanel();
            StackPanel stackHor  = new StackPanel();
            StackPanel stackName = new StackPanel();

            stackName.Margin = new Thickness(2);
            TextBlock blockName = new TextBlock();

            blockName.Text = "差值";
            stackName.Children.Add(blockName);
            StackPanel stackValue = new StackPanel();

            stackValue.Margin = new Thickness(2);
            TextBlock blockValue = new TextBlock();

            block = blockValue;
            stackValue.Children.Add(blockValue);
            stackHor.Children.Add(stackName);
            stackHor.Children.Add(stackValue);
            stackVer.Children.Add(stackHor);
            grid.Children.Add(stackVer);
            chaLine.ToolTip    = grid;
            chaLine.Visibility = Visibility.Visible;
            dataChart.Series.Add(chaLine);
        }