Beispiel #1
0
        public WpfMultiChart()
        {
            InitializeComponent();

            LoadImages();

            //do not show no data label by default
            ShowNoDataLabel(false);

            dataSeries = new List<TimeSeriesData>();
            plotSeries = new TimeSeriesData();
            shapeTransform = new MatrixTransform();
            chartClip = new PathGeometry();
            optimalGridLineSpacing = new Point(100, 50);
            adorner = new AdornerCursor2(ChartInteractiveCanvas, shapeTransform);
            adorner.CanvasSize = new Size(ChartInteractiveCanvas.ActualWidth, ChartInteractiveCanvas.ActualHeight);

            adorner.PanCursorImage = panCursor;

            panZoomCalculator = new PanZoomCalculator();

            ChartCanvas.SizeChanged += new SizeChangedEventHandler(ChartCanvas_SizeChanged);
            ChartCanvas.IsVisibleChanged += new DependencyPropertyChangedEventHandler(ChartCanvas_IsVisibleChanged);

            NoDataLabel.MouseMove += new MouseEventHandler(NoDataLabel_MouseMove);
            AttachEventsToCanvas(ChartInteractiveCanvas);

            ResizeChart();
        }
Beispiel #2
0
        private TimeSeriesDataPoint GetInterpolatedDataPointFromMouseCoordinates(TimeSeriesData Series, Point mousePos)
        {
            TimeSeriesDataPoint dataPoint = new TimeSeriesDataPoint();
            dataPoint.TimeStamp = DateTime.Now;
            dataPoint.Value = double.NaN;

            Point pos = mousePos;
            pos.Y = ChartInteractiveCanvas.ActualHeight - pos.Y;

            GeneralTransform inverse = shapeTransform.Inverse;
            if (inverse != null)
            {
                pos = inverse.Transform(pos);
                DateTime xVal = Series.FromPointSeconds(pos.X);
                double yVal = Series.GetClosedInterpolatedValue(xVal);

                dataPoint.TimeStamp = xVal;
                dataPoint.Value = yVal;

            }

            return dataPoint;
        }
Beispiel #3
0
 public void AddSeries(TimeSeriesData series)
 {
     series.PlotSizeChanged += new PlotSizeChangedDelegate(dataSeries_PlotSizeChanged);
     dataSeries.Add(series);
 }
Beispiel #4
0
        private void FillSampleData()
        {
            mChart.ClearAllSeries();

            TimeSeriesData data1 = new TimeSeriesData();
            data1.Name = "LG001";
            data1.StrokeColor = Colors.DarkBlue;
            data1.IsAreaMode = false;
            data1.Clear();

            TimeSeriesData data2 = new TimeSeriesData();
            data2.Name = "LG002";
            data2.StrokeColor = Colors.Red;
            data2.IsAreaMode = false;
            data2.Clear();

            TimeSeriesData data3 = new TimeSeriesData();
            data3.Name = "LG003";
            data3.StrokeColor = Colors.Green;
            data3.IsAreaMode = false;
            data3.Clear();

            RandomDataSeries ranData1 = new RandomDataSeries();
            Thread.Sleep(137);
            RandomDataSeries ranData2 = new RandomDataSeries();
            Thread.Sleep(153);
            RandomDataSeries ranData3 = new RandomDataSeries();
            ranData1.ValueScale = 300;
            ranData2.ValueScale = 400;
            ranData2.SampleFrequencyPerMin = 0.8;
            ranData3.ValueScale = 200;
            ranData3.SampleFrequencyPerMin = 0.5;

            List<TimeSeriesDataPoint> points1 = new List<TimeSeriesDataPoint>();
            ranData1.ReSeed();
            for (int i = 0; i <= 65; i++)
            {
                points1.Add(ranData1.NextDataPoint);
            }

            List<TimeSeriesDataPoint> points2 = new List<TimeSeriesDataPoint>();
            ranData2.ReSeed();
            for (int i = 0; i <= 13; i++)
            {
                points2.Add(ranData2.NextDataPoint);
            }

            List<TimeSeriesDataPoint> points3 = new List<TimeSeriesDataPoint>();
            ranData3.ReSeed();
            for (int i = 0; i <= 8; i++)
            {
                points3.Add(ranData3.NextDataPoint);
            }

            mChart.AddSeries(data1);
            mChart.AddSeries(data2);
            mChart.AddSeries(data3);

            data1.AddPointsRange(points1.ToArray());
            data2.AddPointsRange(points2.ToArray());
            data3.AddPointsRange(points3.ToArray());
        }