public void SetData(Double[] xValues, Double[] yValues)
        {
            // Only accept resolution count of data points.

            if (xValues.Length > m_iResolution)
            {
                Array.Resize(ref xValues, m_iResolution);
            }

            if (yValues.Length > m_iResolution)
            {
                Array.Resize(ref yValues, m_iResolution);
            }

            _chart.BeginUpdate();

            // Set data to area series.

            Int32 iPointCount = xValues.Length;

            AreaSeriesPoint[] aPoints = new AreaSeriesPoint[iPointCount];
            for (Int32 i = 0; i < iPointCount; i++)
            {
                aPoints[i].X = xValues[i];
                aPoints[i].Y = yValues[i];
            }

            _chart.ViewXY.AreaSeries[0].Points = aPoints;

            _chart.EndUpdate();
        }
Exemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();

            // Create chart.
            var chart = new LightningChartUltimate();

            // Disable rendering before updating chart properties to improve performance
            // and to prevent unnecessary chart redrawing while changing multiple properties.
            chart.BeginUpdate();

            // Set chart control into parent container.
            chart.Parent = this;           // Set form as parent.
            chart.Dock   = DockStyle.Fill; // Maximize to parent client area.

            // Define variables for X- and Y-axis.
            var axisX = chart.ViewXY.XAxes[0];
            var axisY = chart.ViewXY.YAxes[0];

            // Set axis names.
            axisX.Title.Text = "X-axis value";
            axisY.Title.Text = "Y-axis value";

            // Set legendbox placement.
            chart.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;

            // 1. Create a new AreaSeries.
            var areaSeries1 = new AreaSeries(chart.ViewXY, axisX, axisY);

            // Add styling for created series.
            areaSeries1.Fill.Color        = Color.LightSteelBlue;
            areaSeries1.LineStyle.Color   = Color.Black;
            areaSeries1.Fill.GradientFill = GradientFill.Solid;

            // 2. Define AreaSeriesPoints and add them to AreaSeries.
            AreaSeriesPoint[] points1 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 10),
                new AreaSeriesPoint(1, 8),
                new AreaSeriesPoint(2, 9),
                new AreaSeriesPoint(3, 8),
                new AreaSeriesPoint(4, 7),
                new AreaSeriesPoint(5, 8),
                new AreaSeriesPoint(6, 7),
                new AreaSeriesPoint(7, 9),
                new AreaSeriesPoint(9, 8),
                new AreaSeriesPoint(10, 9)
            };

            // Add points to series.
            areaSeries1.AddValues(points1);

            // 3. Add AreaSeries to chart.
            chart.ViewXY.AreaSeries.Add(areaSeries1);

            // 4. Create 2 new AreaSeries.
            var areaSeries2 = new AreaSeries(chart.ViewXY, axisX, axisY);
            var areaSeries3 = new AreaSeries(chart.ViewXY, axisX, axisY);

            // Add styling for created series.
            areaSeries2.Fill.Color        = Color.LightGoldenrodYellow;
            areaSeries2.LineStyle.Color   = Color.Black;
            areaSeries2.Fill.GradientFill = GradientFill.Solid;

            areaSeries3.Fill.Color        = Color.DarkOrange;
            areaSeries3.LineStyle.Color   = Color.Black;
            areaSeries3.Fill.GradientFill = GradientFill.Solid;

            // 5. Define AreaSeriesPoints for both new AreaSeries and add them to AreaSeries.
            AreaSeriesPoint[] points2 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 5),
                new AreaSeriesPoint(1, 7),
                new AreaSeriesPoint(3, 5),
                new AreaSeriesPoint(4, 6),
                new AreaSeriesPoint(5, 3),
                new AreaSeriesPoint(6, 5),
                new AreaSeriesPoint(7, 6),
                new AreaSeriesPoint(8, 7),
                new AreaSeriesPoint(9, 5),
                new AreaSeriesPoint(10, 4)
            };

            AreaSeriesPoint[] points3 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 1),
                new AreaSeriesPoint(1, 3),
                new AreaSeriesPoint(3, 1),
                new AreaSeriesPoint(4, 3),
                new AreaSeriesPoint(5, 2),
                new AreaSeriesPoint(6, 3),
                new AreaSeriesPoint(7, 2),
                new AreaSeriesPoint(8, 4),
                new AreaSeriesPoint(9, 1),
                new AreaSeriesPoint(10, 2)
            };

            // Add points to series.
            areaSeries2.AddValues(points2);
            areaSeries3.AddValues(points3);

            // 6. Add AreaSeries to chart.
            chart.ViewXY.AreaSeries.Add(areaSeries2);
            chart.ViewXY.AreaSeries.Add(areaSeries3);

            // Auto-scale X- and Y-axes.
            chart.ViewXY.ZoomToFit();

            #region Hidden polishing
            // Customize chart.
            CustomizeChart(chart);
            #endregion

            // Call EndUpdate to enable rendering again.
            chart.EndUpdate();
        }
        public MainWindow()
        {
            InitializeComponent();

            // Create chart.
            // This is done using XAML.

            // Disable rendering before updating chart properties to improve performance
            // and to prevent unnecessary chart redrawing while changing multiple properties.
            chart.BeginUpdate();

            // Create variable for view from ViewXY.
            // This is done using XAML.

            // 1. Create a new AreaSeries.
            // This is done using XAML.

            // Add styling for created series.
            areaSeries1.Fill.Color        = Color.FromRgb(176, 196, 222); // LightSteelBlue.
            areaSeries1.LineStyle.Color   = Color.FromRgb(0, 0, 0);       // Black.
            areaSeries1.Fill.GradientFill = GradientFill.Solid;

            // 2. Define AreaSeriesPoints and add them to AreaSeries.
            AreaSeriesPoint[] points1 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 10),
                new AreaSeriesPoint(1, 8),
                new AreaSeriesPoint(2, 9),
                new AreaSeriesPoint(3, 8),
                new AreaSeriesPoint(4, 7),
                new AreaSeriesPoint(5, 8),
                new AreaSeriesPoint(6, 7),
                new AreaSeriesPoint(7, 9),
                new AreaSeriesPoint(9, 8),
                new AreaSeriesPoint(10, 9)
            };

            // Add points to series.
            areaSeries1.AddValues(points1);

            // 3. Add AreaSeries to chart.
            // This is done using XAML.

            // 4. Create 2 new AreaSeries.
            // This is done using XAML.

            // Add styling for created series.
            areaSeries2.Fill.Color        = Color.FromRgb(250, 250, 210); // LightGoldenrodYellow.
            areaSeries2.LineStyle.Color   = Color.FromRgb(0, 0, 0);       // Black.
            areaSeries2.Fill.GradientFill = GradientFill.Solid;

            areaSeries3.Fill.Color        = Color.FromRgb(255, 140, 0); // DarkOrange.
            areaSeries3.LineStyle.Color   = Color.FromRgb(0, 0, 0);     // Black.
            areaSeries3.Fill.GradientFill = GradientFill.Solid;

            // 5. Define AreaSeriesPoints for both new AreaSeries and add them to AreaSeries.
            AreaSeriesPoint[] points2 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 5),
                new AreaSeriesPoint(1, 7),
                new AreaSeriesPoint(3, 5),
                new AreaSeriesPoint(4, 6),
                new AreaSeriesPoint(5, 3),
                new AreaSeriesPoint(6, 5),
                new AreaSeriesPoint(7, 6),
                new AreaSeriesPoint(8, 7),
                new AreaSeriesPoint(9, 5),
                new AreaSeriesPoint(10, 4)
            };

            AreaSeriesPoint[] points3 = new AreaSeriesPoint[] {
                new AreaSeriesPoint(0, 1),
                new AreaSeriesPoint(1, 3),
                new AreaSeriesPoint(3, 1),
                new AreaSeriesPoint(4, 3),
                new AreaSeriesPoint(5, 2),
                new AreaSeriesPoint(6, 3),
                new AreaSeriesPoint(7, 2),
                new AreaSeriesPoint(8, 4),
                new AreaSeriesPoint(9, 1),
                new AreaSeriesPoint(10, 2)
            };

            // Add points to series.
            areaSeries2.AddValues(points2);
            areaSeries3.AddValues(points3);

            // 6. Add AreaSeries to chart.
            // This is done using XAML.

            // Auto-scale X- and Y-axes.
            chart.ViewXY.ZoomToFit();

            #region Hidden polishing
            // Customize chart.
            CustomizeChart(chart);
            #endregion

            // Call EndUpdate to enable rendering again.
            chart.EndUpdate();
        }