/// <summary> /// 频谱仪自适应 /// </summary> public void FitView() { double minY = double.MaxValue; double maxY = double.MinValue; double y; _chart.BeginUpdate(); if (_grid != null && m_aFastData != null) { for (int i = 0; i < m_iSizeTimeSlots; i++) { for (int j = 0; j < m_iSizeResolution; j++) { y = m_aFastData[i][j]; if (y > maxY) { maxY = y; } if (y < minY) { minY = y; } } } _grid.ValueRangePalette = CreatePalette(_grid, maxY); } _chart.EndUpdate(); }
private void OnOrthoDataChanged(OrthoDataChangedEventArgs args) { double[] xArray = args.XArray; double[] yArray = args.YArray; if (xArray.Length == yArray.Length && xArray.Length != 0) { m_chart.BeginUpdate(); FreeformPointLineSeries series = m_chart.ViewXY.FreeformPointLineSeries[0]; if (series.Points == null || series.Points.Length != xArray.Length) { series.Points = new SeriesPoint[xArray.Length]; } for (int i = 0; i < xArray.Length; i++) { series.Points[i].X = xArray[i]; series.Points[i].Y = yArray[i]; } series.InvalidateData(); m_chart.ViewXY.ZoomToFit(); m_chart.EndUpdate(); } else { m_chart.BeginUpdate(); m_chart.ViewXY.FreeformPointLineSeries[0].Clear(); m_chart.EndUpdate(); } }
private void RPM3DSpectrumView_Loaded(object sender, RoutedEventArgs e) { ViewModel = DataContext as RPM3DSpectrumDataViewModel; if (ViewModel != null) { rpm3Dchart.BeginUpdate(); m_surface.SetSize(ViewModel.SizeX, ViewModel.SizeY); rpm3Dchart.EndUpdate(); if (rpm3DSpectrumSubscrible != null) { rpm3DSpectrumSubscrible.Dispose(); } rpm3DSpectrumSubscrible = ViewModel.WhenPropertyChanged.Where(o => o.ToString() == "RPM3DSpectrumData").ObserveOn(uiContext).Subscribe(OnRPM3DSpectrumDataChanged); } }
private void OnSnapshotDataChanged(SnapshotAMSContract2 contract) { try { showAMSCheckBox.IsChecked = true; m_chart.BeginUpdate(); if (contract != null) { if (m_chart.ViewXY.PointLineSeries[1].PointCount > 0) { m_chart.ViewXY.PointLineSeries[1].Clear(); } //htzk123,数据 //var snapshotItems = contract.Item.OrderBy(o => o.STIME).ToArray(); //int length = snapshotItems.Length; //SeriesPoint[] points = new SeriesPoint[length]; //for (int i = 0; i < length; i++) //{ // points[i].X = m_chart.ViewXY.XAxes[0].DateTimeToAxisValue(snapshotItems[i].STIME); // points[i].Y = snapshotItems[i].AMS; // points[i].Tag = snapshotItems[i].id; //} //if (length > 0) //{ // if (m_chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis < points[0].X || m_chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis > points[length-1].X) // m_chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis = points[length / 2].X; //} // //m_chart.ViewXY.PointLineSeries[0].Points = points; m_chart.ViewXY.ZoomToFit(); } else { ViewModel.CurrentSnapshotContract = null; if (m_chart.ViewXY.PointLineSeries[0].PointCount > 0) { m_chart.ViewXY.PointLineSeries[0].Clear(); } } m_chart.EndUpdate(); } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-报警点趋势-趋势", ex)); m_chart.EndUpdate(); } }
// 6. Generate data. public void GenerateData(int columns, int rows) { // Create variable for storing data. double data = 0; // Disable rendering before updating chart properties to improve performance // and to prevent unnecessary chart redrawing while changing multiple properties. _chart.BeginUpdate(); // Set data values and add them to SurfaceGrid. for (int i = 0; i < _columns; i++) { for (int j = 0; j < _rows; j++) { // Add values to the SurfaceGrid as SurfacePoints, points are distributed by using following function. data = 30.0 + 8 * Math.Cos(20 + 0.0001 * (double)(i * j)) + 60.0 * Math.Cos((double)(j - i) * 0.01); _surfaceGrid.Data[i, j].Y = data; } } // Notify chart about updated data. _surfaceGrid.InvalidateData(); // Call EndUpdate to enable rendering again. _chart.EndUpdate(); }
// 5. Generate data. public void GenerateData(int columns, int rows) { // Create new IntensityPoint series for data. var data = new IntensityPoint[_columns, _rows]; // Disable rendering before updating chart properties to improve performance // and to prevent unnecessary chart redrawing while changing multiple properties. _chart.BeginUpdate(); // Set data values and add them to Heat Map. for (int i = 0; i < _columns; i++) { for (int j = 0; j < _rows; j++) { // Add values to the IntensityPoint series, points are generated by using following function. data[i, j].Value = 30.0 + 20 * Math.Cos(20 + 0.0001 * (double)(i * j)) + 70.0 * Math.Cos((double)(j - i) * 0.01); } } // Add generated data as Heat Map data. _heatMap.Data = data; // Call EndUpdate to enable rendering again. _chart.EndUpdate(); }
private void UpdateChart(OrderAnalysisObject order) { try { if (order == null) { return; } m_chart.BeginUpdate(); m_chart.View3D.XAxisPrimary3D.SetRange(0, order.MaxXValue); m_chart.View3D.YAxisPrimary3D.SetRange(0, order.MaxYValue); m_series.ContourPalette = CreatePalette(m_series, order.MaxYValue); m_chart.View3D.ZAxisPrimary3D.SetRange(0, order.MaxZValue); m_series.Data = order.SurfacePointArray; //m_series.InvalidateData(); m_chart.EndUpdate(); } catch (Exception ex) { EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-阶次分析", ex)); m_chart.EndUpdate(); } }
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(); }
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); }
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); }
// 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(); }
// 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(); }
private void DrawTime3D(Tuple <float[], float[]> turple) { if (turple != null) { time3Dchart.BeginUpdate(); m_dCurrentZ += 1; SurfacePoint[,] surfaceData = m_surface.Data; double dZMin = m_dCurrentZ - (time3Dchart.View3D.ZAxisPrimary3D.Maximum - time3Dchart.View3D.ZAxisPrimary3D.Minimum); double dZMax = m_dCurrentZ; var datas = turple.Item2.Select(o => (double)o).ToArray(); double yMax = datas.Max(); if (time3Dchart.View3D.YAxisPrimary3D.Maximum < yMax) { m_surface.ContourPalette = CreatePalette(m_surface, yMax); time3Dchart.View3D.YAxisPrimary3D.SetRange(0, yMax * 1.2); } var xMax = turple.Item1.Max(); if (xMax != time3Dchart.View3D.XAxisPrimary3D.Maximum) { time3Dchart.View3D.XAxisPrimary3D.SetRange(0, xMax); m_surface.SetRangesXZ(time3Dchart.View3D.XAxisPrimary3D.Minimum, time3Dchart.View3D.XAxisPrimary3D.Maximum, time3Dchart.View3D.ZAxisPrimary3D.Minimum, time3Dchart.View3D.ZAxisPrimary3D.Maximum); } if (m_surface.SizeX != datas.Length) { if (m_surface.CheckSurfaceSizeForGPU(datas.Length, 100)) { m_surface.SetSize(datas.Length, 100); messageTxt.Text = string.Empty; } else { messageTxt.Text = string.Format("当前显卡不支持点数:{0}X{1}", datas.Length, 100); } } m_surface.InsertRowBackAndScroll(datas, dZMin, dZMax, dZMin, dZMax); time3Dchart.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(); }
private void OnDataChanged(object args) { m_chart.BeginUpdate(); FreeformPointLineSeries ps = m_chart.ViewXY.FreeformPointLineSeries[0]; if (ViewModel is BaseDivfreChannelToken) { var vChannel = ViewModel as BaseDivfreChannelToken; if (vChannel.DataContracts != null) { SeriesPoint[] points = new SeriesPoint[vChannel.DataContracts.Count]; for (int i = 0; i < vChannel.DataContracts.Count; i++) { points[i].X = (vChannel.DataContracts[i] as IBaseDivfreSlot).RPM ?? 0; points[i].Y = vChannel.DataContracts[i].Result ?? 0; } ps.Points = points; } } else if (ViewModel is DivFreChannelToken) { var divChannel = ViewModel as DivFreChannelToken; if (divChannel.DataContracts != null) { SeriesPoint[] points = new SeriesPoint[divChannel.DataContracts.Count]; for (int i = 0; i < divChannel.DataContracts.Count; i++) { var rpm = (from p in divChannel.SlotDataContracts where p.RecordLab == divChannel.DataContracts[i].RecordLab select p.RPM).FirstOrDefault(); if (rpm == null) { continue; } points[i].X = rpm ?? 0; points[i].Y = divChannel.DataContracts[i].Result ?? 0; } ps.Points = points; } } m_chart.ViewXY.ZoomToFit(); m_chart.EndUpdate(); }
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); }
private void OnDataChanged(object args) { m_chart.BeginUpdate(); FreeformPointLineSeries ps = m_chart.ViewXY.FreeformPointLineSeries[0]; if (ViewModel is VibrationChannelToken) { var vChannel = ViewModel as VibrationChannelToken; if (vChannel.DataContracts != null) { SeriesPoint[] points = new SeriesPoint[vChannel.DataContracts.Length]; for (int i = 0; i < vChannel.DataContracts.Length; i++) { points[i].X = vChannel.DataContracts[i].RPM ?? 0; points[i].Y = vChannel.DataContracts[i].Value; } ps.Points = points; } } else if (ViewModel is DivFreChannelToken) { var divChannel = ViewModel as DivFreChannelToken; if (divChannel.DataContracts != null) { SeriesPoint[] points = new SeriesPoint[divChannel.DataContracts.Length]; for (int i = 0; i < divChannel.DataContracts.Length; i++) { points[i].X = divChannel.DataContracts[i].RPM; points[i].Y = divChannel.DataContracts[i].FreMV; } ps.Points = points; } } m_chart.ViewXY.FitView(); m_chart.EndUpdate(); }
/// <summary> /// 图表初始化 /// </summary> /// <param name="samplingFrequency">采样频率</param> /// <param name="title">示波器标题</param> /// <param name="scrollMode">示波器缩放模式</param> /// <param name="xAxisLen">x轴长度</param> public void Initialize(double samplingFrequency, string title, XAxisScrollMode scrollMode, double xAxisLen) { _samplingFrequency = samplingFrequency; _chart.BeginUpdate(); _chart.Title.Text = title; _chart.ViewXY.SampleDataSeries[0].Clear(); _chart.ViewXY.SampleDataSeries[0].SamplingFrequency = samplingFrequency; _chart.ViewXY.SampleDataSeries[0].FirstSampleTimeStamp = 0; _chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Horizontal; _chart.ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.None; _chart.ViewXY.XAxes[0].ScrollMode = scrollMode; _chart.ViewXY.XAxes[0].ScrollPosition = 0; _chart.ViewXY.XAxes[0].SetRange(0, xAxisLen); _chart.ViewXY.XAxes[0].Title.Text = string.Format("{0} s", xAxisLen.ToString("0.000")); _chart.ViewXY.DropOldSeriesData = true; //_chart.ViewXY.LineSeriesCursors[0].Visible = false; _chart.EndUpdate(); }
/// <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(); }
private void verticalCursor_PositionChanged(object sender, PositionChangedEventArgs e) { if (_tfdata == null) { return; } //Solve nearest row data row double dColStep = (_tfSeries.RangeMaxX - _tfSeries.RangeMinX) / (double)(_dataFileNode.NFrame - 1); int iColIndex = (int)((e.NewValue - _tfSeries.RangeMinX) / dColStep); if (iColIndex < 0) { iColIndex = 0; } if (iColIndex > _dataFileNode.NFrame - 1) { iColIndex = _dataFileNode.NFrame - 1; } if (oldiColIndex == iColIndex) { return; } else { oldiColIndex = iColIndex; } float[] data = new float[_dataFileNode.Nfft]; Array.Copy(_throughputdata[_selectChannelIndex], iColIndex * _dataFileNode.FrameDN, data, 0, _dataFileNode.Nfft); _timeGraph.BeginUpdate(); //_timeSeries.FirstSampleTimeStamp = iColIndex * _dataFileNode.FrameDN / _dataFileNode.fs; _timeSeries.SamplesSingle = data; _timeGraph.ViewXY.ZoomToFit(); _timeGraph.EndUpdate(); _freqGraph.BeginUpdate(); _freqSeries.SamplesDouble = _tfdata[iColIndex]; _freqGraph.ViewXY.ZoomToFit(); _freqGraph.EndUpdate(); _throughputgraph_verticalCursor.ValueAtXAxis = iColIndex * _dataFileNode.FrameDN / _dataFileNode.fs + _dataFileNode.Nfft / _dataFileNode.fs / 2; }
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); }
public void UpdateGrid() { Chart.BeginUpdate(); var t = timer.Elapsed.TotalSeconds; for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { grid.Data[x, z].Y = fluid.WaterLevelAt(x, z); ground.Data[x, z].Y = fluid.GroundLevelAt(x, z); } } grid.InvalidateData(); ground.InvalidateData(); Chart.EndUpdate(); }
private void HandleVibrationMessage(VibrationMessage message) { try { m_chart.BeginUpdate(); var vParm = message.VParm; StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("有效值:{0}", vParm.AMS.ToString("0.00"))); sb.AppendLine(string.Format("峰值:{0}", vParm.PeakValue.ToString("0.00"))); sb.AppendLine(string.Format("峰峰值:{0}", vParm.PeakPeakValue.ToString("0.00"))); sb.AppendLine(string.Format("斜度:{0}", vParm.Slope.ToString("0.00"))); sb.AppendLine(string.Format("峭度:{0}", vParm.Kurtosis.ToString("0.00"))); sb.AppendLine(string.Format("峭度指标:{0}", vParm.KurtosisIndex.ToString("0.00"))); sb.AppendLine(string.Format("波形指标:{0}", vParm.WaveIndex.ToString("0.00"))); sb.AppendLine(string.Format("峰值指标:{0}", vParm.PeakIndex.ToString("0.00"))); sb.AppendLine(string.Format("脉冲指标:{0}", vParm.ImpulsionIndex.ToString("0.00"))); sb.AppendLine(string.Format("裕度指标:{0}", vParm.ToleranceIndex.ToString("0.00"))); if (message.IsCepstrum) { m_chart.ViewXY.SampleDataSeries[0].SamplingFrequency = message.SampleFre / 1000; } else { m_chart.ViewXY.SampleDataSeries[0].SamplingFrequency = 1; } m_chart.ViewXY.SampleDataSeries[0].SamplesDouble = message.VData; m_chart.ViewXY.SampleDataSeries[0].InvalidateData(); m_chart.ViewXY.Annotations[0].Text = sb.ToString().Trim(); //if (fitViewCheckBox.IsChecked == true) //{ m_chart.ViewXY.ZoomToFit(); //} m_chart.EndUpdate(); } catch (Exception ex) { m_chart.EndUpdate(); } }
void UpdateChannel() { int i, j; _mplayer.Close(); _throughputGraph.BeginUpdate(); _throughputSeries.SamplesSingle = _throughputdata[_selectChannelIndex]; _rmsSeries.SamplesSingle = _rmsData[_selectChannelIndex]; _throughputGraph.ViewXY.ZoomToFit(); _throughputGraph.EndUpdate(); _tfGraph.BeginUpdate(); _tfdata = new double[_dataFileNode.NFrame][]; float[] curdata = new float[_dataFileNode.Nfft]; float[] fdata = null; int curind = 0; for (i = 0; i < _dataFileNode.NFrame; i++) { Array.Copy(_throughputdata[_selectChannelIndex], curind, curdata, 0, _dataFileNode.Nfft); curind += _dataFileNode.FrameDN; spectrumCalculator.PowerSpectrum(curdata, out fdata); _tfdata[i] = new double[flen]; for (j = 0; j < flen; j++) { _tfdata[i][j] = 20 * Math.Log10(fdata[j + fstarti]) + _aweightdb[j]; } } _tfSeries.SetValuesData(_tfdata, IntensityGridValuesDataOrder.ColumnsRows); _tfGraph.ViewXY.ZoomToFit(); _tfGraph.EndUpdate(); oldiColIndex = -1; verticalCursor_PositionChanged(null, new PositionChangedEventArgs() { NewValue = _tfgraph_verticalCursor.ValueAtXAxis }); }
// 7. Create a function for mouse move event handler. private void _chart_MouseMove(object sender, MouseEventArgs e) { // Call BeginUpdate for chart to disable rendering while mouse is moving // over the chart to improve performance. chart.BeginUpdate(); // Set label visible when not hovered over by mouse. mouseAnnotation.Visible = false; // Check if any object has been found under the mouse. object obj = chart.GetActiveMouseOverObject(); if (obj != null) { // Check if the active mouse over object is a PointLineSeries object. if (obj is PointLineSeries3D) { PointLineSeries3D pointLineSeries3D = obj as PointLineSeries3D; // Get the point last hit by mouse. int pointIndex = pointLineSeries3D.LastMouseHitTestIndex; SeriesPoint3D point = pointLineSeries3D.Points[pointIndex]; // Set annotation position to the moused over point. mouseAnnotation.TargetAxisValues.SetValues(point.X, point.Y, point.Z); // Set annotation text to display information about the moused over point. mouseAnnotation.Text = "Series index: " + chart.View3D.PointLineSeries3D.IndexOf(pointLineSeries3D).ToString() + "\nPoint index: " + pointIndex.ToString() + "\nX=" + point.X.ToString("0.0") + " ; Y=" + point.Y.ToString("0.0") + " ; Z=" + point.Z.ToString("0.0"); // Set the annotation visible while mouse is hovering over the point. mouseAnnotation.Visible = true; } } // Call EndUpdate to enable rendering again after handling mouse move event. 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(); }
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. 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); }
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); }