Exemple #1
0
        public static Example LargeDataSetNarrow()
        {
            var pm = new PlotModel {
                Title = "Large Data Set (narrow window)"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "Time",
                DataFieldHigh       = "H",
                DataFieldLow        = "L",
                DataFieldOpen       = "O",
                DataFieldClose      = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
            };

            var n = 1000000;

            foreach (var bar in HighLowItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            timeSpanAxis1.Minimum = series.Items[0].X;
            timeSpanAxis1.Maximum = series.Items[29].X;

            linearAxis1.Minimum = series.Items.Take(30).Select(x => x.Low).Min();
            linearAxis1.Maximum = series.Items.Take(30).Select(x => x.High).Max();

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Exemple #2
0
        public static Example SmallDataSet()
        {
            var pm = new PlotModel {
                Title = "Small Data Set"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var n      = 100;
            var items  = HighLowItemGenerator.MRProcess(n).ToArray();
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "X",
                DataFieldHigh       = "High",
                DataFieldLow        = "Low",
                DataFieldOpen       = "Open",
                DataFieldClose      = "Close",
                TrackerFormatString =
                    "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                ItemsSource = items
            };

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }