void CustomizeChart(LightningChartUltimate chart)
 {
     chart.ChartBackground.Color        = Color.FromArgb(255, 30, 30, 30);
     chart.ChartBackground.GradientFill = GradientFill.Solid;
     chart.Title.Color          = Color.FromArgb(255, 249, 202, 3);
     chart.Title.MouseHighlight = MouseOverHighlight.None;
 }
Exemple #2
0
        void CusomizeChart(LightningChartUltimate chart)
        {
            chart.Background.Color                    = Color.FromArgb(255, 30, 30, 30);
            chart.Background.GradientFill             = GradientFill.Solid;
            chart.ViewXY.GraphBackground.Color        = Color.FromArgb(255, 20, 20, 20);
            chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            chart.Title.Color          = Color.FromArgb(255, 249, 202, 3);
            chart.Title.MouseHighlight = MouseOverHighlight.None;

            foreach (var yAxis in chart.ViewXY.YAxes)
            {
                yAxis.Title.Color               = Color.FromArgb(255, 249, 202, 3);
                yAxis.Title.MouseHighlight      = MouseOverHighlight.None;
                yAxis.MajorGrid.Color           = Color.FromArgb(35, 255, 255, 255);
                yAxis.MajorGrid.Pattern         = LinePattern.Solid;
                yAxis.MinorDivTickStyle.Visible = false;
            }

            foreach (var xAxis in chart.ViewXY.XAxes)
            {
                xAxis.Title.Color               = Color.FromArgb(255, 249, 202, 3);
                xAxis.Title.MouseHighlight      = MouseOverHighlight.None;
                xAxis.MajorGrid.Color           = Color.FromArgb(35, 255, 255, 255);
                xAxis.MajorGrid.Pattern         = LinePattern.Solid;
                xAxis.MinorDivTickStyle.Visible = false;
                xAxis.ValueType = AxisValueType.Number;
            }
        }
 private void Dispose()
 {
     if (_chart != null)
     {
         _chart.Dispose();
         _chart = null;
     }
 }
 public void Dispose()
 {
     if (_chart != null)
     {
         _chart.Dispose();
         _chart = null;
     }
 }
Exemple #5
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate(LicenseKeyStrings.LightningChartUltimate);
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";
            m_chart.ViewXY.AxisLayout.YAxesLayout        = YAxesLayout.Segmented;
            m_chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;
            // m_chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].Minimum           = 0;
            m_chart.ViewXY.XAxes[0].Maximum           = 1000;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            m_chart.ViewXY.YAxes.Clear();
            m_chart.ViewXY.AxisLayout.Segments.Clear();

            m_chart.ViewXY.LegendBox.Visible        = true;
            m_chart.ViewXY.LegendBox.Layout         = LegendBoxLayout.VerticalColumnSpan;
            m_chart.ViewXY.LegendBox.Fill.Style     = RectFillStyle.None;
            m_chart.ViewXY.LegendBox.Shadow.Visible = false;
            m_chart.ViewXY.LegendBox.BorderWidth    = 0;
            m_chart.ViewXY.LegendBox.Position       = LegendBoxPosition.TopRight;
            m_chart.ViewXY.LegendBox.Offset.SetValues(-50, 10);
            m_chart.ViewXY.LegendBox.SeriesTitleFont = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.PositionChanged  += new LineSeriesCursor.PositionChangedHandler(cursor_PositionChanged);
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.LineStyle.Width   = 2;
            cursor.SnapToPoints      = true;
            cursor.TrackPoint.Color1 = Colors.White;
            m_chart.ViewXY.FitView();
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);
        }
        public MainWindow()
        {
            InitializeComponent();

            // Create chart.
            chart = new LightningChartUltimate();
            (Content as Grid).Children.Add(chart);

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

            // 1. Set View3D as active view and set Z-axis range.
            chart.ActiveView = ActiveView.View3D;
            chart.View3D.ZAxisPrimary3D.SetRange(0, 80);

            // Create 3D PointLines with pre-generated data and different colors to the chart.
            CreatePointLine(0, Colors.Red);
            CreatePointLine(1, Colors.Orange);
            CreatePointLine(2, Colors.Yellow);
            CreatePointLine(3, Colors.Green);
            CreatePointLine(4, Colors.Blue);
            CreatePointLine(5, Colors.Indigo);
            CreatePointLine(6, Colors.Violet);

            // 5. Create a new annotation to display target values when hovering over a point with the mouse.
            mouseAnnotation = new Annotation3D(chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary)
            {
                Visible = false,
                TargetCoordinateSystem   = AnnotationTargetCoordinates.AxisValues,
                LocationCoordinateSystem = CoordinateSystem.RelativeCoordinatesToTarget,
                MouseInteraction         = false
            };

            // Set offset to annotation.
            mouseAnnotation.LocationRelativeOffset.SetValues(40, -70);

            // Add annotation to View3D.
            chart.View3D.Annotations.Add(mouseAnnotation);

            // 6. Add mouse move event handler to chart to enable tracking points with the mouse.
            chart.MouseMove += Chart_MouseMove;

            // Set chart's title and default camera rotation.
            chart.Title.Text = "3D Point Lines";
            chart.View3D.Camera.RotationX = 30;
            chart.View3D.Camera.RotationY = -50;

            #region Hidden polishing
            CustomizeChart(chart);
            #endregion

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

            // Safe disposal of LightningChart components when the window is closed.
            Closed += new EventHandler(Window_Closed);
        }
        // Create chart.
        public void CreateChart()
        {
            // Create chart.
            _chart = new LightningChartUltimate();

            // Set chart control into the parent container.
            _chart.Parent = this;
            _chart.Dock   = DockStyle.Fill;

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

            // Set a LegendBox into a chart with vertical layout.
            _chart.ViewXY.LegendBoxes[0].Layout = LegendBoxLayout.Vertical;

            // Configure X- and Y-axis.
            var axisX = _chart.ViewXY.XAxes[0];
            var axisY = _chart.ViewXY.YAxes[0];

            axisX.Title.Text = "X-Axis Position";
            axisX.SetRange(MinX, MaxX);
            axisY.Title.Text = "Y-Axis Position";
            axisY.SetRange(MinY, MaxY);

            // 1. Create a Heat Map instance as IntensityGridSeries.
            _heatMap = new IntensityGridSeries(_chart.ViewXY, axisX, axisY);

            // Set Heat Map's contents and properties.
            _heatMap.LegendBoxUnits   = "°C";
            _heatMap.Title.Text       = "Heat Map";
            _heatMap.MouseInteraction = false;
            _heatMap.PixelRendering   = false;
            _heatMap.SetRangesXY(MinX, MaxX, MinY, MaxY);
            _heatMap.SetSize(_columns, _rows);

            // Create a ValueRangePalette to present Heat Map's data.
            if (_heatMap.ValueRangePalette != null)
            {
                _heatMap.ValueRangePalette.Dispose();
            }
            _heatMap.ValueRangePalette = CreatePalette(_heatMap);

            // Add Heat Map to chart.
            _chart.ViewXY.IntensityGridSeries.Add(_heatMap);

            // 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();
        }
        // Safe disposal of LightningChart components when the form is closed.
        private void Form_Closed(Object sender, FormClosedEventArgs e)
        {
            // Dispose Chart.
            _chart.Dispose();
            _chart = null;

            // Dispose Heat Map.
            _heatMap.Dispose();
            _heatMap = null;
        }
Exemple #9
0
        // Safe disposal of LightningChart components when the window is closed.
        private void Window_Closed(object window_Closed, System.EventArgs e)
        {
            // Dispose Chart.
            _chart.Dispose();
            _chart = null;

            // Dispose Heat Map.
            _heatMap.Dispose();
            _heatMap = null;
        }
Exemple #10
0
        // Safe disposal of LightningChart components when the form is closed.
        private void Form_Closed(Object sender, FormClosedEventArgs e)
        {
            // Dispose Chart.
            _chart.Dispose();
            _chart = null;

            // Dispose SurfaceGrid.
            _surfaceGrid.Dispose();
            _surfaceGrid = null;
        }
        /// <summary>
        /// 清空示波器数据
        /// </summary>
        public void Dispose()
        {
            if (_chart != null)
            {
                _parentControl.Children.Remove(_chart);

                _chart.Dispose();
                _chart = null;
            }
        }
Exemple #12
0
        // Create chart instance.
        public void CreateChart()
        {
            // Create chart.
            _chart = new LightningChartUltimate();

            // Set chart control into the parent container.
            _chart.Parent = this;
            _chart.Dock   = DockStyle.Fill;

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

            // 1. Set View3D as active view and set Y-axis range.
            _chart.ActiveView = ActiveView.View3D;
            _chart.View3D.YAxisPrimary3D.SetRange(-50, 100);

            // Set a LegendBox into a chart with vertical layout.
            _chart.View3D.LegendBox.Layout = LegendBoxLayout.Vertical;

            // 2. Create a new SurfaceGrid instance as SurfaceGridSeries3D.
            _surfaceGrid = new SurfaceGridSeries3D(_chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);

            // 3. Set range, size and color saturation options for SurfaceGrid.
            _surfaceGrid.RangeMinX = MinX;
            _surfaceGrid.RangeMaxX = MaxX;
            _surfaceGrid.RangeMinZ = MinZ;
            _surfaceGrid.RangeMaxZ = MaxZ;
            _surfaceGrid.SizeX     = _columns;
            _surfaceGrid.SizeZ     = _rows;

            // Stronger colors.
            _surfaceGrid.ColorSaturation = 80;

            // 4. Create ValueRangePalette for coloring SurfaceGrid's data.
            ValueRangePalette palette = CreatePalette(_surfaceGrid);

            _surfaceGrid.ContourPalette = palette;

            // 5. Define WireFrameType and ContourLineType for SurfaceGrid.
            _surfaceGrid.WireframeType    = SurfaceWireframeType3D.WireframePalettedByY;
            _surfaceGrid.ContourLineType  = ContourLineType3D.ColorLineByY;
            _surfaceGrid.ContourLineWidth = 2;

            // Add SurfaceGridSeries to chart.
            _chart.View3D.SurfaceGridSeries3D.Add(_surfaceGrid);

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

            // Call EndUpdate to enable rendering again.
            _chart.EndUpdate();
        }
        public Form1()
        {
            InitializeComponent();

            // 1. 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();

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

            // 3. Generate data for series.
            var rand         = new Random();
            int pointCounter = 70;

            var data = new SeriesPoint[pointCounter];

            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = rand.Next(0, 100);
            }

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

            // 5. Create a new PointLineSeries.
            var series = new PointLineSeries(chart.ViewXY, axisX, axisY);

            series.LineStyle.Color = Color.Orange;

            // 6. Set data-points into series.
            series.Points = data;

            // 7. Add series to chart.
            chart.ViewXY.PointLineSeries.Add(series);

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

            #region Hidden polishing

            CustomizeChart(chart);

            #endregion

            // Call EndUpdate to enable rendering again.
            chart.EndUpdate();
        }
Exemple #14
0
 private void OnDisposed(object args)
 {
     gridChart.Children.Clear();
     if (m_chart != null)
     {
         m_chart.Dispose();
         m_chart = null;
     }
     dataChangedSubscription.Dispose();
     disposedSubscription.Dispose();
 }
Exemple #15
0
 protected void ViewModel_Closed(object sender, EventArgs e)
 {
     // Don't forget to clear chart grid child list.
     gridChart.Children.Clear();
     if (m_chart != null)
     {
         m_chart.Dispose();
         m_chart = null;
     }
     base.Dispose();
     base.GCCollect();
 }
Exemple #16
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate();
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";
            m_chart.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
            m_chart.ViewXY.AxisLayout.YAxesLayout             = YAxesLayout.Stacked;
            m_chart.ViewXY.LegendBoxes[0].Visible             = false;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            m_chart.ViewXY.YAxes[0].Title.Visible     = false;
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.YAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            FreeformPointLineSeries series = new FreeformPointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);

            series.MouseInteraction       = false;
            series.LineStyle.AntiAliasing = LineAntialias.None;
            series.LineStyle.Width        = 1;

            m_chart.ViewXY.FreeformPointLineSeries.Add(series);

            m_chart.ViewXY.ZoomToFit();
            m_chart.EndUpdate();
            gridChart.Children.Add(m_chart);
        }
Exemple #17
0
        /// <summary>
        /// 创建三维饼图
        /// </summary>
        private void CreatePie3D()
        {
            _chartPie3D = new LightningChartUltimate();

            // Disable rendering, strongly recommended before updating chart properties.
            _chartPie3D.BeginUpdate();

            // Change active view to Pie3D view.
            _chartPie3D.ActiveView = ActiveView.ViewPie3D;

            _chartPie3D.Parent     = panel1;
            _chartPie3D.Dock       = DockStyle.Fill;
            _chartPie3D.Name       = "Pie3D chart";
            _chartPie3D.Title.Text = "预警模块";

            // Configure background.
            _chartPie3D.Background.GradientFill  = GradientFill.Radial;
            _chartPie3D.Background.GradientColor = Color.Black;

            // Configure 3D pie view.
            _chartPie3D.ViewPie3D.Style    = PieStyle3D.Pie;
            _chartPie3D.ViewPie3D.Rounding = 40; // Set pie rounding.


            // Configure legend.
            _chartPie3D.ViewPie3D.LegendBox3DPie.Layout   = LegendBoxLayout.HorizontalRowSpan;
            _chartPie3D.ViewPie3D.LegendBox3DPie.Position = LegendBoxPosition.BottomCenter;
            _chartPie3D.ViewPie3D.LegendBox3DPie.Visible  = false;

            // Add pie slice data.
            // By using TRUE as a last parameter, the slice will be automatically added to chart.ViewPie3D.Values collection.
            PieSlice slice1 = new PieSlice("铁水温度", Color.FromArgb(150, 255, 255, 0), 8, _chartPie3D.ViewPie3D, true);

            slice1.Title.Font = new Font("黑体", 10);
            PieSlice slice2 = new PieSlice("铁水硅含量", Color.FromArgb(150, 0, 0, 255), 6, _chartPie3D.ViewPie3D, true);

            slice2.Title.Font = new Font("黑体", 10);
            PieSlice slice3 = new PieSlice("铁水流速", Color.FromArgb(150, 0, 255, 255), 5, _chartPie3D.ViewPie3D, true);

            slice3.Title.Font = new Font("黑体", 10);
            PieSlice slice4 = new PieSlice("铁水出铁量", Color.FromArgb(150, 255, 0, 255), 2, _chartPie3D.ViewPie3D, true);

            slice4.Title.Font = new Font("黑体", 10); //slice1.Title.Color = PublicColor.FromArgb(255, Color.Black);

            _chartPie3D.EndUpdate();
        }
Exemple #18
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate(LicenseKeyStrings.LightningChartUltimate);
            m_chart.BeginUpdate();
            m_chart.Title.Visible = false;
            m_chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            //m_chart.ViewXY.XAxes[0].LabelsPosition = Alignment.Near;
            //m_chart.ViewXY.XAxes[0].MajorDivTickStyle.Alignment = Alignment.Near;
            //m_chart.ViewXY.XAxes[0].MajorDivTickStyle.Color = Color.FromArgb(100, 135, 205, 238);
            //m_chart.ViewXY.XAxes[0].MinorDivTickStyle.Alignment = Alignment.Near;
            //m_chart.ViewXY.XAxes[0].MinorDivTickStyle.Color = Color.FromArgb(100, 135, 205, 238);
            //m_chart.ViewXY.XAxes[0].VerticalAlign = AlignmentVertical.Top;

            m_chart.ViewXY.YAxes.Clear();
            m_chart.ViewXY.LegendBox.Visible = false;

            m_chart.ViewXY.FitView();
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);
        }
Exemple #19
0
        public Form1()
        {
            InitializeComponent();

            // 1. Create chart instance and store it member variable.
            var chart = new LightningChartUltimate(/*Type your License key here...*/);

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

            // 3. Prepare data for line-series.
            var rand         = new Random();
            int pointCounter = 70;

            var data = new SeriesPoint[pointCounter];

            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = rand.Next(0, 100);
            }

            // 4. Add PointLineSeries for variable-interval data, progressing by X.
            var series = new PointLineSeries(chart.ViewXY, chart.ViewXY.XAxes[0], chart.ViewXY.YAxes[0]);

            series.LineStyle.Color = Color.Orange;

            // 5. Set data-points into series.
            series.Points = data;

            // 6. Add the series into list of point-line-series.
            chart.ViewXY.PointLineSeries.Add(series);

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

            #region Hiden polishing

            CusomizeChart(chart);

            #endregion
        }
        public View()
        {
            _zoomBarChart = null;

            InitializeComponent();


            //var csvdata = CsvRead.readCSVWithHeader(path, true, "/", ",", true);

            //foreach (var item in csvdata)
            //{
            //    var _loadspindle = item;
            //    foreach (var item2 in _loadspindle)
            //    {
            //        if (item2.Key == "LoadSpindle")
            //        {
            //            double loadspindle = Convert.ToDouble(item2.Value);
            //            DL_LoadSpindel.Add(loadspindle);
            //            Console.WriteLine(loadspindle);
            //        }
            //    }
            //}
        }
Exemple #21
0
        public void AddToChart(LightningChartUltimate chart)
        {
            Chart = chart;

            var xAxis = chart.ViewXY.XAxes[0];
            var yAxis = chart.ViewXY.YAxes[0];
            var color = Config.Color;

            // Initialize left cursor
            Left = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Left.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Left.FullHeight        = false;
            Left.SnapToPoints      = false;
            Left.Style             = CursorStyle.PointTracking;
            Left.TrackPoint.Color1 = Colors.Transparent;
            Left.TrackPoint.Color2 = Colors.Transparent;
            Left.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Left);

            // Initialize right cursor
            Right = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Right.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Right.FullHeight        = false;
            Right.SnapToPoints      = false;
            Right.Style             = CursorStyle.PointTracking;
            Right.TrackPoint.Color1 = Colors.Transparent;
            Right.TrackPoint.Color2 = Colors.Transparent;
            Right.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Right);

            // Initialize middle cursor
            Middle = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Middle.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Middle.FullHeight        = false;
            Middle.SnapToPoints      = false;
            Middle.Style             = CursorStyle.PointTracking;
            Middle.TrackPoint.Color1 = Colors.Transparent;
            Middle.TrackPoint.Color2 = Colors.Transparent;
            Middle.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Middle);

            //Edit bands
            BandBar = new Band(Chart.ViewXY, xAxis, yAxis)
            {
                Title   = { Text = string.Empty },
                Behind  = true,
                Binding = AxisBinding.XAxis
            };
            var bandColor = Config.BandColor;

            BandBar.Fill.Color             = Color.FromArgb(bandColor.A, bandColor.R, bandColor.G, bandColor.B);
            BandBar.Fill.GradientColor     = ChartTools.CalcGradient(BandBar.Fill.Color, Color.FromArgb(150, 0, 0, 0), 50);
            BandBar.Fill.GradientDirection = 0;

            BandBar.Title.Visible = true;
            BandBar.Title.Color   = Colors.White;
            BandBar.MouseResize   = false;
            Chart.ViewXY.Bands.Add(BandBar);

            BandBar.MovedByMouse += (sender, args) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middle = (BandBar.ValueBegin + BandBar.ValueEnd) / 2;
                var diff   = middle - Value;

                var left  = Left.ValueAtXAxis + diff;
                var right = Right.ValueAtXAxis + diff;

                SetByValue(right, left, middle);

                // resize bandwidth
                //var middleDiff = Middle.ValueAtXAxis - BandBar.ValueBegin;
                //if (middleDiff >= 0)
                //{
                //    Range.Start = -middleDiff;
                //    Range.End = middleDiff;
                //}
                //else
                //{
                //    Range.Start = 0;
                //    Range.End = 0;
                //}

                //if (middleDiff > Config.BandwidthMaximum)
                //{
                //    Range.Start = -Config.BandwidthMaximum;
                //    Range.End = Config.BandwidthMaximum;
                //}

                //var right = Middle.ValueAtXAxis + Range.End;
                //var left = Middle.ValueAtXAxis + Range.Start;
                //var middle = Middle.ValueAtXAxis;

                //SetByValue(right, left, middle);

                _isChanging = false;
            };

            Right.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middleDiff = Right.ValueAtXAxis - Middle.ValueAtXAxis;
                if (middleDiff >= 0)
                {
                    Range.Start = -middleDiff;
                    Range.End   = middleDiff;
                }
                else
                {
                    Range.Start = 0;
                    Range.End   = 0;
                }

                if (middleDiff > Config.BandwidthMaximum)
                {
                    Range.Start = -Config.BandwidthMaximum;
                    Range.End   = Config.BandwidthMaximum;
                }

                var right  = Middle.ValueAtXAxis + Range.End;
                var left   = Middle.ValueAtXAxis + Range.Start;
                var middle = Middle.ValueAtXAxis;

                SetByValue(right, left, middle);

                _isChanging = false;
            };

            Left.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middleDiff = Middle.ValueAtXAxis - Left.ValueAtXAxis;
                if (middleDiff >= 0)
                {
                    Range.Start = -middleDiff;
                    Range.End   = middleDiff;
                }
                else
                {
                    Range.Start = 0;
                    Range.End   = 0;
                }

                if (middleDiff > Config.BandwidthMaximum)
                {
                    Range.Start = -Config.BandwidthMaximum;
                    Range.End   = Config.BandwidthMaximum;
                }

                var right  = Middle.ValueAtXAxis + Range.End;
                var left   = Middle.ValueAtXAxis + Range.Start;
                var middle = Middle.ValueAtXAxis;

                SetByValue(right, left, middle);

                _isChanging = false;
            };

            Middle.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var diff = value - Value;

                var left  = Left.ValueAtXAxis + diff;
                var right = Right.ValueAtXAxis + diff;

                SetByValue(right, left, value);

                _isChanging = false;
            };
        }
        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 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 title options for X- and Y-axis.
            axisX.Title.Visible = false;
            axisY.Title.Text    = "Temperature °C";

            // Set label angle for X-axis.
            axisX.LabelsAngle = 90;

            // LegendBox layout.
            chart.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.SegmentTopRight;

            // Disable autoformating of labels.
            axisX.AutoFormatLabels = false;

            // Enable CustomAxisTicks.
            axisX.CustomTicksEnabled = true;

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

            // Add styling to created series.
            barSeries1.Fill.Color        = Color.Orange;
            barSeries1.Fill.GradientFill = GradientFill.Solid;
            barSeries1.Title.Text        = "2017";
            barSeries1.BarThickness      = 10;

            // 2. Generate data as BarSeriesValues to represent average monthly temperatures.
            BarSeriesValue[] bars1 = new BarSeriesValue[]
            {
                new BarSeriesValue(0, -5, null),
                new BarSeriesValue(1, -6, null),
                new BarSeriesValue(2, -2, null),
                new BarSeriesValue(3, 4, null),
                new BarSeriesValue(4, 10, null),
                new BarSeriesValue(5, 14, null),
                new BarSeriesValue(6, 17, null),
                new BarSeriesValue(7, 15, null),
                new BarSeriesValue(8, 10, null),
                new BarSeriesValue(9, 6, null),
                new BarSeriesValue(10, -2, null),
                new BarSeriesValue(11, -4, null)
            };

            // Add BarSeriesValues to BarSeries.
            barSeries1.Values = bars1;

            // 3. Add BarSeries to chart.
            chart.ViewXY.BarSeries.Add(barSeries1);

            // 4. Create second BarSeries.
            var barSeries2 = new BarSeries();

            // Add styling to created series.
            barSeries2.Fill.Color        = Color.LightGray;
            barSeries2.Fill.GradientFill = GradientFill.Solid;
            barSeries2.Title.Text        = "2018";
            barSeries2.BarThickness      = 10;

            // 5. Generate an other set of data as BarSeriesValues to represent average monthly temperatures.
            BarSeriesValue[] bars2 = new BarSeriesValue[]
            {
                new BarSeriesValue(0, -1, null),
                new BarSeriesValue(1, -1, null),
                new BarSeriesValue(2, 2, null),
                new BarSeriesValue(3, 8, null),
                new BarSeriesValue(4, 15, null),
                new BarSeriesValue(5, 19, null),
                new BarSeriesValue(6, 21, null),
                new BarSeriesValue(7, 19, null),
                new BarSeriesValue(8, 14, null),
                new BarSeriesValue(9, 8, null),
                new BarSeriesValue(10, 2, null),
                new BarSeriesValue(11, -7, null)
            };

            // Add BarSeriesValues to BarSeries.
            barSeries2.Values = bars2;

            // 6. Add BarSeries to chart.
            chart.ViewXY.BarSeries.Add(barSeries2);

            // 7. Configure bar view layout.
            chart.ViewXY.BarViewOptions.Grouping = BarsGrouping.ByLocation;

            // 8. Create list of months.
            string[] months = new string[]
            {
                "January",
                "February",
                "March",
                "April",
                "May",
                "June",
                "July",
                "August",
                "September",
                "October",
                "November",
                "December"
            };

            // 9. Create CustomAxisTicks to display months as X-axis values.
            for (int i = 0; i < months.Length; i++)
            {
                CustomAxisTick tick = new CustomAxisTick(axisX);
                tick.AxisValue = i;
                tick.LabelText = months[i];
                tick.Color     = Color.FromArgb(35, 255, 255, 255);

                axisX.CustomTicks.Add(tick);
            }

            // Notify chart about set custom axis ticks.
            axisX.InvalidateCustomTicks();

            // 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();
        }
Exemple #24
0
        public WaveformMonitor(Color lineColor, string title = "")
        {
            SampleFrequency = 0.0;

            ContainerChart = new LightningChartUltimate
            {
                Name                = "Chart1",
                ChartName           = "Chart1",
                Title               = { Text = title },
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            ContainerChart.BeginUpdate();

            ContainerChart.ViewXY.AxisLayout.AutoAdjustMargins = false;
            ContainerChart.ViewXY.DropOldSeriesData            = false;

            _xAxis                           = ContainerChart.ViewXY.XAxes[0];
            _xAxis.ValueType                 = AxisValueType.Number;
            _xAxis.SweepingGap               = 2;
            _xAxis.ScrollMode                = XAxisScrollMode.None;
            _xAxis.Title.Text                = "Range";
            _xAxis.Title.VerticalAlign       = XAxisTitleAlignmentVertical.Top;
            _xAxis.Title.HorizontalAlign     = XAxisTitleAlignmentHorizontal.Right;
            _xAxis.LabelsPosition            = Alignment.Near;
            _xAxis.LabelsFont                = new WPFFont("Tahoma", 9.0, "9", true, false);
            _xAxis.MajorDivTickStyle.Visible = false;
            _xAxis.MinorDivTickStyle.Visible = false;
            _xAxis.MajorGrid.Visible         = false;
            _xAxis.MinorGrid.Visible         = false;
            _xAxis.LabelsVisible             = true;
            _xAxis.SteppingInterval          = 1;
            _xAxis.MouseScaling              = false;
            _xAxis.MouseScrolling            = false;
            _xAxis.MouseInteraction          = false;
            _xAxis.AxisThickness             = 1;

            var axisY = ContainerChart.ViewXY.YAxes[0];

            axisY.SetRange(0, 30000);
            axisY.Title.Visible = false;
            axisY.LabelsFont    = new WPFFont("Tahoma", 9.0, "9", true, false);

            ContainerChart.ViewXY.GraphBackground.GradientDirection = 270;
            ContainerChart.ViewXY.GraphBackground.GradientFill      = GradientFill.Cylindrical;

            var color = ContainerChart.ViewXY.GraphBackground.Color;

            ContainerChart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B);

            ContainerChart.Title.Font = new WPFFont("Tahoma", 11.0, "11", true, false);

            ContainerChart.Title.Align = ChartTitleAlignment.TopCenter;
            ContainerChart.Title.Offset.SetValues(0, 25);
            ContainerChart.Title.Color = lineColor;

            ContainerChart.ViewXY.Margins = new Thickness(70, 10, 15, 10);
            ContainerChart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime;

            ContainerChart.ChartBackground.Color             = ChartTools.CalcGradient(lineColor, Colors.Black, 65);
            ContainerChart.ChartBackground.GradientDirection = 0;
            ContainerChart.ChartBackground.GradientFill      = GradientFill.Cylindrical;

            ContainerChart.ViewXY.LegendBox.Visible = false;

            var series = new SampleDataSeries(ContainerChart.ViewXY, _xAxis, axisY)
            {
                LineStyle =
                {
                    Width        =        1f,
                    Color        = lineColor,
                    AntiAliasing = LineAntialias.None
                },
                MouseInteraction = false
            };

            ContainerChart.ViewXY.SampleDataSeries.Add(series);

            ContainerChart.EndUpdate();
        }
        public MainWindow()
        {
            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 the parent container.
            (Content as Grid).Children.Add(chart);

            // Generate data for first series.
            var rand         = new Random();
            int pointCounter = 70;

            var data = new SeriesPoint[pointCounter];

            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = rand.Next(0, 100);
            }

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

            // Create a new PointLineSeries and add it to the list of PointLineSeries.
            var series = new PointLineSeries(chart.ViewXY, axisX, axisY);

            series.LineStyle.Color = Colors.Orange;
            series.Title.Text      = "Random data";
            series.Points          = data;
            chart.ViewXY.PointLineSeries.Add(series);

            // 1. Generate new data for second series.
            data = new SeriesPoint[pointCounter];
            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = Math.Sin(i * 0.2) * 50 + 50;
            }

            // 2. Create another PointLineSeries and set new color and line-pattern for it.
            var series2 = new PointLineSeries(chart.ViewXY, chart.ViewXY.XAxes[0], chart.ViewXY.YAxes[0]);

            series2.LineStyle.Color   = Color.FromArgb(255, 255, 67, 0);
            series2.LineStyle.Pattern = LinePattern.DashDot;
            series2.Title.Text        = "Sinus data";

            // 3. Set data-points into series.
            series2.Points = data;

            // 4. Add series to chart.
            chart.ViewXY.PointLineSeries.Add(series2);

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

            #region Hidden polishing

            CustomizeChart(chart);

            #endregion

            // Call EndUpdate to enable rendering again.
            chart.EndUpdate();
        }
        private void CreateChart()
        {
            // Clear any gridChart's children.
            gridChart.Children.Clear();

            if (m_chart != null)
            {
                // If a chart is already created, dispose it.
                m_chart.Dispose();
                m_chart = null;
            }

            // Create a new chart.
            m_chart            = new LightningChartUltimate(LicenseKeyStrings.LightningChartUltimate);
            m_chart.Title.Text = "";


            //Disable rendering, strongly recommended before updating chart properties
            m_chart.BeginUpdate();

            //Set active view
            m_chart.ActiveView = ActiveView.View3D;
            //Chart name
            m_chart.ChartName                    = "Point cloud chart";
            m_chart.Background                   = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill = GradientFill.Solid;

            //Setup LegendBox
            m_chart.View3D.LegendBox.Layout   = LegendBoxLayout.VerticalColumnSpan;
            m_chart.View3D.LegendBox.Position = LegendBoxPosition.TopRight;
            m_chart.View3D.LegendBox.SurfaceScales.ScaleSizeDim1 = 150;
            m_chart.View3D.LegendBox.SurfaceScales.ScaleSizeDim2 = 20;
            m_chart.View3D.LegendBox.ShowCheckboxes = false;
            m_chart.View3D.LegendBox.Position       = LegendBoxPosition.TopRight;
            m_chart.View3D.LegendBox.Offset.SetValues(0, 0);
            m_chart.View3D.LegendBox.Fill.Style       = RectFillStyle.None;
            m_chart.View3D.LegendBox.Shadow.Visible   = false;
            m_chart.View3D.LegendBox.BorderWidth      = 0;
            m_chart.View3D.LegendBox.SeriesTitleColor = Colors.White;
            m_chart.View3D.LegendBox.ValueLabelColor  = Colors.White;
            m_chart.View3D.LegendBox.SurfaceScales.ScaleBorderColor = Colors.White;

            m_series = new SurfaceMeshSeries3D(m_chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
            m_chart.View3D.SurfaceMeshSeries3D.Add(m_series);
            m_series.Title.Text = "";

            m_series.ColorSaturation          = 100;
            m_series.WireframeType            = SurfaceWireframeType.DotsPaletted;
            m_series.ContourLineType          = ContourLineType.None;
            m_series.Fill                     = SurfaceFillStyle.None;
            m_series.InitialValue             = -10;
            m_series.ContourPalette           = CreatePalette(m_series, 1);
            m_series.WireframeLineStyle.Width = 3;

            SurfacePoint[,] seriesData = new SurfacePoint[iColumnCount, iRowCount];
            SurfacePoint invalidPoint = new SurfacePoint(0, -100, 0, Colors.White);

            for (int i = 0; i < iColumnCount; i++)
            {
                for (int j = 0; j < iRowCount; j++)
                {
                    seriesData[i, j] = invalidPoint;
                }
            }
            m_series.Data = seriesData;

            //Hide walls
            foreach (WallBase wall in m_chart.View3D.GetWalls())
            {
                wall.Visible = false;
            }

            //Set camera
            m_chart.View3D.Camera.MinimumViewDistance = 30;
            m_chart.View3D.Camera.RotationX          += 10;

            //Set Y dimensions a little bit higher than default
            m_chart.View3D.Dimensions.Y = 80;

            //Set axis ranges
            m_chart.View3D.XAxisPrimary3D.SetRange(0, 1);
            m_chart.View3D.XAxisPrimary3D.Title.Text = "倍频";
            m_chart.View3D.YAxisPrimary3D.SetRange(0, 1);
            m_chart.View3D.YAxisPrimary3D.Title.Text = "幅值";
            m_chart.View3D.ZAxisPrimary3D.SetRange(0, 1);
            m_chart.View3D.ZAxisPrimary3D.Title.Text = "转速";

            //Allow chart rendering
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);
        }
Exemple #27
0
 // Safe disposal of LightningChart components when the form is closed.
 private void Form_Closed(Object sender, FormClosedEventArgs e)
 {
     // Dispose Chart.
     chart.Dispose();
     chart = null;
 }
Exemple #28
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate();
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";
            m_chart.ViewXY.AxisLayout.XAxisAutoPlacement      = XAxisAutoPlacement.BottomThenTop;
            m_chart.ViewXY.AxisLayout.YAxisAutoPlacement      = YAxisAutoPlacement.LeftThenRight;
            m_chart.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
            m_chart.ViewXY.AxisLayout.YAxesLayout             = YAxesLayout.Layered;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.LegendBoxes[0].Visible = false;

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.DateTime;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);


            m_chart.ViewXY.YAxes[0].Title.Visible     = false;
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.YAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            m_chart.ViewXY.YAxes[0].Title.Text        = "";

            AxisX xAxis2 = new AxisX(m_chart.ViewXY);

            xAxis2.LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            xAxis2.Title.Text        = "";
            xAxis2.AxisColor         = DefaultColors.SeriesForBlackBackgroundWpf[1];
            xAxis2.MajorGrid.Visible = false;
            xAxis2.ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes.Add(xAxis2);

            AxisY yAxis2 = new AxisY(m_chart.ViewXY);

            yAxis2.LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            yAxis2.Title.Text        = "";
            yAxis2.AxisColor         = DefaultColors.SeriesForBlackBackgroundWpf[1];
            yAxis2.MajorGrid.Visible = false;
            m_chart.ViewXY.YAxes.Add(yAxis2);

            PointLineSeries series = new PointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);

            series.MouseInteraction       = false;
            series.LineStyle.AntiAliasing = LineAntialias.None;
            series.LineStyle.Width        = 1;
            m_chart.ViewXY.PointLineSeries.Add(series);

            PointLineSeries series2 = new PointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[1], m_chart.ViewXY.YAxes[1]);

            series2.MouseInteraction       = false;
            series2.LineStyle.Color        = DefaultColors.SeriesForBlackBackgroundWpf[1];
            series2.LineStyle.AntiAliasing = LineAntialias.None;
            series2.LineStyle.Width        = 1;
            series2.CursorTrackEnabled     = false;
            m_chart.ViewXY.PointLineSeries.Add(series2);

            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            cursor.PositionChanged += AlarmPointTrendDataView_PositionChanged;
            //cursor.AssignXAxisIndex = 0;
            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.SnapToPoints      = true;
            cursor.LineStyle.Width   = 2;
            cursor.TrackPoint.Color1 = Colors.White;

            m_chart.ViewXY.ZoomToFit();
            m_chart.EndUpdate();
            gridChart.Children.Add(m_chart);
        }
        public MainWindow()
        {
            InitializeComponent();

            // Create chart instance and store it member variable
            var chart = new LightningChartUltimate(/*Set your License key here..*/);

            // Set chart control into the parent container.
            (Content as Grid).Children.Add(chart);

            // Prepare data for line-series.
            var rand         = new Random();
            int pointCounter = 70;

            var data = new SeriesPoint[pointCounter];

            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = rand.Next(0, 100);
            }

            // Add PointLineSeries for variable-interval data, progressing by X.
            var series = new PointLineSeries(chart.ViewXY, chart.ViewXY.XAxes[0], chart.ViewXY.YAxes[0]);

            series.LineStyle.Color = Colors.Orange;
            series.Title.Text      = "Random data";
            series.Points          = data;
            chart.ViewXY.PointLineSeries.Add(series);

            // 1. Prepare new data for new line-series with differen algorithm.
            data = new SeriesPoint[pointCounter];
            for (int i = 0; i < pointCounter; i++)
            {
                data[i].X = (double)i;
                data[i].Y = Math.Sin(i * 0.2) * 50 + 50;
            }

            // 2. Add one more PointLineSeries for sinusoidal data.
            // Configure by setting another color and pattern for the line.
            var series2 = new PointLineSeries(chart.ViewXY, chart.ViewXY.XAxes[0], chart.ViewXY.YAxes[0]);

            series2.LineStyle.Color   = Color.FromArgb(255, 255, 67, 0);
            series2.LineStyle.Pattern = LinePattern.DashDot;
            series2.Title.Text        = "Sinus data";

            // 3. Set data-points into series.
            series2.Points = data;

            // 4. Add the series into list of point-line-series.
            chart.ViewXY.PointLineSeries.Add(series2);

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

            #region Hiden polishing

            CusomizeChart(chart);

            #endregion
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="parentControl">父容器</param>
        /// <param name="seriesNames">示波器各序列名</param>
        /// <param name="sampleFrequency">绘制曲线颜色</param>
        /// <param name="titleColor">绘制曲线颜色</param>
        /// <param name="chartManager"> 内置图表的的chartManager(可空)</param>
        public WaveformMonitor(
            Panel parentControl,
            string[] seriesNames,
            double sampleFrequency,
            Color titleColor,
            ChartManager chartManager
            )
        {
            _samplingFrequency = sampleFrequency;
            _parentControl     = parentControl;

            _chart                     = new LightningChartUltimate();
            _chart.ChartName           = "Waveform chart";
            _chart.ViewXY.XAxes        = ViewXY.CreateDefaultXAxes();
            _chart.ViewXY.YAxes        = ViewXY.CreateDefaultYAxes();
            _chart.VerticalAlignment   = VerticalAlignment.Top;
            _chart.HorizontalAlignment = HorizontalAlignment.Left;

            _chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;
            _chart.ViewXY.AxisLayout.SegmentsGap = 10;

            parentControl.Children.Add(_chart);

            _chart.BeginUpdate();
            _chart.ChartManager = chartManager;

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;

            _chart.ViewXY.DropOldSeriesData          = true;
            _chart.ChartRenderOptions.AntiAliasLevel = 0; // Disable hw anti-aliasing.

            AxisX axisX = _chart.ViewXY.XAxes[0];

            axisX.Maximum                   = 10;
            axisX.SweepingGap               = 2;
            axisX.ScrollMode                = XAxisScrollMode.Scrolling;
            axisX.Title.Text                = "Range";
            axisX.Title.VerticalAlign       = XAxisTitleAlignmentVertical.Top;
            axisX.Title.HorizontalAlign     = XAxisTitleAlignmentHorizontal.Right;
            axisX.LabelsPosition            = Alignment.Near;
            axisX.LabelsFont                = new WpfFont("Segoe UI", 11, true, false);
            axisX.MajorDivTickStyle.Visible = false;
            axisX.MinorDivTickStyle.Visible = false;
            axisX.MajorGrid.Visible         = false;
            axisX.MinorGrid.Visible         = false;
            axisX.LabelsVisible             = false;
            axisX.SteppingInterval          = 1;
            axisX.MouseScaling              = false;
            axisX.MouseScrolling            = false;
            axisX.AxisThickness             = 1;

            //AxisY axisY = _chart.ViewXY.YAxes[0];
            //axisY.SetRange(-30000, 30000);
            //axisY.Title.Visible = false;
            //axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);

            _chart.ViewXY.GraphBackground.GradientDirection = 270;
            _chart.ViewXY.GraphBackground.GradientFill      = GradientFill.Cylindrical;

            Color color = _chart.ViewXY.GraphBackground.Color;

            _chart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B);

            _chart.Title.Font = new WpfFont("Segoe UI", 14, true, false);

            _chart.Title.Align = ChartTitleAlignment.TopCenter;
            _chart.Title.Offset.SetValues(0, 25);
            _chart.Title.Color = titleColor;

            _chart.ViewXY.Margins = new Thickness(70, 10, 15, 10);
            _chart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime;

            _chart.ChartBackground.Color             = ChartTools.CalcGradient(titleColor, Colors.Black, 65);
            _chart.ChartBackground.GradientDirection = 0;
            _chart.ChartBackground.GradientFill      = GradientFill.Cylindrical;

            //清除之前的y轴与数据序列
            DisposeAllAndClear(_chart.ViewXY.YAxes);
            DisposeAllAndClear(_chart.ViewXY.SampleDataSeries);
            //添加多序列的y轴属性
            for (int index = 0; index < seriesNames.Count(); index++)
            {
                AxisY axisY = new AxisY(_chart.ViewXY);
                axisY.SetRange(-30000, 30000);
                axisY.Title.Font    = new WpfFont("Segoe UI", 10, false, false);
                axisY.Title.Text    = string.Format(seriesNames[index]);
                axisY.Title.Angle   = 0;
                axisY.Units.Visible = false;
                //axisY.Title.Visible = false;
                axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);
                _chart.ViewXY.YAxes.Add(axisY);

                //Add SampleDataSeries
                SampleDataSeries sds = new SampleDataSeries(_chart.ViewXY, axisX, axisY);
                _chart.ViewXY.SampleDataSeries.Add(sds);
                sds.SampleFormat              = SampleFormat.DoubleFloat;
                sds.LineStyle.Color           = DefaultColors.SeriesForBlackBackgroundWpf[index % DefaultColors.SeriesForBlackBackgroundWpf.Length];
                sds.SamplingFrequency         = _samplingFrequency;
                sds.FirstSampleTimeStamp      = 1.0 / _samplingFrequency;
                sds.LineStyle.Width           = 1f;
                sds.LineStyle.AntiAliasing    = LineAntialias.None;
                sds.ScrollModePointsKeepLevel = 1;
                sds.ScrollingStabilizing      = true;
                sds.MouseInteraction          = false;



                //Add the line as a zero level
                ConstantLine cls = new ConstantLine(_chart.ViewXY, axisX, axisY);
                cls.Title.Text       = "Constant line";
                cls.Title.Visible    = false;
                cls.LineStyle.Color  = Colors.BlueViolet;
                cls.Behind           = true;
                cls.LineStyle.Width  = 2;
                cls.MouseInteraction = false;
                cls.Value            = 0;
                _chart.ViewXY.ConstantLines.Add(cls);
            }

            //LineSeriesCursor cursor1 = new LineSeriesCursor(_chart.ViewXY, axisX);
            //cursor1.ValueAtXAxis = 1;
            //cursor1.LineStyle.Width = 6;

            //color = Colors.OrangeRed;
            //cursor1.LineStyle.Color = Color.FromArgb(180, color.R, color.G, color.B);

            //cursor1.FullHeight = true;
            //cursor1.SnapToPoints = true;
            //cursor1.Style = CursorStyle.PointTracking;
            //cursor1.TrackPoint.Color1 = Colors.Yellow;
            //cursor1.TrackPoint.Color2 = Colors.Transparent;
            //cursor1.TrackPoint.Shape = Shape.Circle;
            //_chart.ViewXY.LineSeriesCursors.Add(cursor1);

            _chart.EndUpdate();
        }