void NewData()
        {
            long             ticks = DateTime.Now.Ticks;
            int              len   = 100;
            List <Quotation> data  = SampleFinancialData.Create(len);

            chart.BeginUpdate();
            chart.Data.ItemsSource = data;
            chart.View.AxisX.Min   = data[0].Time.ToOADate() - 0.5;
            chart.View.AxisX.Max   = data[len - 1].Time.ToOADate() + 0.5;
            chart.EndUpdate();
        }
Ejemplo n.º 2
0
        void NewData()
        {
            chart.BeginUpdate();

            chart.View.AxisX.ScrollBar = new AxisScrollBar();
            chart.View.AxisX.Scale     = 0.125;

            chart.View.AxisX.Title = "Time";

            chart.View.AxisY.PlotAreaIndex = 1;
            chart.View.AxisY.Title         = "Price";

            chart.View.PlotAreas.Add(new PlotArea()
            {
                Row             = 1,
                Stroke          = new SolidColorBrush(Colors.DarkGray),
                StrokeThickness = 0.5,
                Background      = new SolidColorBrush(Colors.Blue)
                {
                    Opacity = 0.1
                }
            });
            chart.View.PlotAreas.Add(new PlotArea()
            {
                Row             = 0,
                Stroke          = new SolidColorBrush(Colors.DarkGray),
                StrokeThickness = 0.5,
                Background      = new SolidColorBrush(Colors.Green)
                {
                    Opacity = 0.1
                }
            });

            chart.View.PlotAreas.RowDefinitions.Add(
                new PlotAreaRowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            chart.View.PlotAreas.RowDefinitions.Add(
                new PlotAreaRowDefinition()
            {
                Height = new GridLength(4, GridUnitType.Star)
            });

            chart.Data.Children.Add(
                new HighLowOpenCloseSeries()
            {
                Label             = "Price",
                XValueBinding     = new Binding("Time"),
                HighValueBinding  = new Binding("High"),
                LowValueBinding   = new Binding("Low"),
                OpenValueBinding  = new Binding("Open"),
                CloseValueBinding = new Binding("Close"),
                SymbolFill        = new SolidColorBrush(Colors.Blue),
                SymbolStroke      = new SolidColorBrush(Colors.Blue)
            });

            chart.Data.Children.Add(
                new XYDataSeries()
            {
                Label         = "Volume",
                AxisY         = "Volume",
                XValueBinding = new Binding("Time"),
                ValueBinding  = new Binding("Volume"),
                ChartType     = ChartType.Column,
                SymbolFill    = new SolidColorBrush(Colors.Green)
            });

            chart.View.Axes.Add(new Axis()
            {
                AxisType        = AxisType.Y,
                Name            = "Volume",
                Title           = "Volume",
                PlotAreaIndex   = 0,
                MajorGridStroke = chart.View.AxisY.MajorGridStroke
            });

            chart.View.PlotAreas.Add(new PlotArea());

            chart.Data.ItemsSource = SampleFinancialData.Create(364);

            chart.ChartType = ChartType.Candle;
            chart.EndUpdate();
        }