Beispiel #1
0
        private void Testme_Click(object sender, RoutedEventArgs e)
        {
            NBDataReader      reader = new NBDataReader();
            List <NBDataItem> items  = reader.GetDataItems();

            MessageBox.Show(items.Count.ToString());

            VM.ChartPointCollection = new System.Collections.ObjectModel.ObservableCollection <NBDataItem>(items);

            //Initialize chart
            myChart.BeginUpdate();
            //Get XY view
            ViewXY chartView = myChart.ViewXY;
            //Get default x-axis and set the range and ValueType
            AxisX axisX = chartView.XAxes[0];

            axisX.SetRange((double)items.Min(x => x.TimeStamp), (double)items.Max(x => x.TimeStamp));
            axisX.ValueType = AxisValueType.Number;
            //Get default y-axis and set the range.
            AxisY axisY = chartView.YAxes[0];

            axisY.SetRange((double)items.Min(x => x.Channels.Min()), (double)items.Max(x => x.Channels.Max()));
            //Add point line series
            for (int i = 0; i < reader.Channels; i++)
            {
                PointLineSeries pls = new PointLineSeries(chartView, axisX, axisY);
                pls.PointsVisible = false;
                SeriesPoint[] aPoints = new SeriesPoint[items.Count];
                for (int iPoint = 0; iPoint < items.Count; iPoint++)
                {
                    aPoints[iPoint].X = items[iPoint].TimeStamp;
                    aPoints[iPoint].Y = items[iPoint].Channels[i];
                }
                //Assign the data for the point line series
                pls.Points     = aPoints;
                pls.Title      = new Arction.WPF.LightningChartUltimate.Titles.SeriesTitle();
                pls.Title.Text = "CHANNEL " + i;
                //Add series to the PointLineSeries container in the view
                chartView.PointLineSeries.Add(pls);
            }
            //Apply chart property changes, which causes chart to be painted
            myChart.EndUpdate();

            MessageBox.Show("OK");
        }
Beispiel #2
0
        internal void Zoom(double factor)
        {
            if (_zoomFactor == 1.0 && factor > 1.0)
            {
                return;
            }
            if (_zoomFactor == 0.0625 && factor < 1.0)
            {
                return;
            }

            _zoomFactor *= factor;
            ContainerChart.BeginUpdate();

            _xAxis.SetRange(_xAxis.Minimum * factor, _xAxis.Maximum * factor);
            _xAxis.ScrollPosition = _xAxis.Minimum;
            _xAxis.Position       = _xAxis.Minimum;

            //var defaultMin = -SampleFrequency/2;
            ContainerChart.ViewXY.SampleDataSeries[0].FirstSampleTimeStamp = _xAxis.Minimum;
            ContainerChart.EndUpdate();
        }
Beispiel #3
0
        /// <summary>
        /// 初始化速度曲线
        /// </summary>
        private void CreateVelocityChart()
        {
            //Create new _chartTemp

            _chartVelocity = new LightningChartUltimate();
            //Disable rendering, strongly recommended before updating chart properties
            _chartVelocity.BeginUpdate();

            //Reduce memory usage and increase performance. Destroys out-scrolled data.
            _chartVelocity.ViewXY.DropOldSeriesData = true;

            _chartVelocity.Parent      = lightningChartUltimate3;
            _chartVelocity.Name        = "Si prediction";
            _chartVelocity.Title.Text  = "铁水实时流速曲线";
            _chartVelocity.Title.Color = PublicColor.FromArgb(255, Color.Yellow);
            _chartVelocity.Title.Font  = new Font("黑体", 10, FontStyle.Bold);
            _chartVelocity.Dock        = DockStyle.Fill;

            // Setup custom style.
            //ExampleUtils.SetStandardFlatStyle(_chartSi);
            _chartVelocity.Background.Color        = PublicColor.FromArgb(255, Color.Gray);
            _chartVelocity.Background.GradientFill = GradientFill.Solid;
            //Configure x-axis
            AxisX xAxis = _chartVelocity.ViewXY.XAxes[0];

            xAxis.ValueType        = AxisValueType.DateTime;
            xAxis.Title.Text       = "Time";
            xAxis.AutoFormatLabels = false;
            //xAxis.LabelsTimeFormat = "dd/MM/yyyy\nHH:mm.ss";
            xAxis.LabelsTimeFormat = "HH:mm.ss";
            xAxis.LabelsAngle      = 0;
            xAxis.ScrollMode       = XAxisScrollMode.Scrolling;
            xAxis.LabelsFont       = new Font("黑体", 6);
            xAxis.LabelsColor      = PublicColor.FromArgb(255, Color.Yellow);
            xAxis.Visible          = false;
            xAxis.Title.Visible    = false;

            //Convert DateTime values to axis values
            DateTime now  = DateTime.Now;
            double   minX = xAxis.DateTimeToAxisValue(now);
            double   maxX = xAxis.DateTimeToAxisValue(now) + 200;

            xAxis.SetRange(minX, maxX);

            //Configure y-axis
            AxisY yAxis = _chartVelocity.ViewXY.YAxes[0];

            yAxis.Title.Text = "Si Predition";
            yAxis.SetRange(4.5, 8);
            yAxis.LabelsFont    = new Font("黑体", 6);
            yAxis.LabelsColor   = PublicColor.FromArgb(255, Color.Yellow);
            yAxis.Title.Visible = false;

            //Configure and add series to the chart
            PointLineSeries series = new PointLineSeries(_chartVelocity.ViewXY, xAxis, yAxis);

            series.LineStyle.Color  = Color.Yellow;
            series.MouseInteraction = false;
            _chartVelocity.ViewXY.PointLineSeries.Add(series);

            //Don't show legendbox
            _chartVelocity.ViewXY.LegendBoxes[0].Visible = false;

            //Allow chart rendering
            _chartVelocity.EndUpdate();
        }
        public AreaSpectrumMonitor(
            Panel parentControl,
            Int32 resolution,
            Double xAxisMax,
            String title,
            Color lineColor
            )
        {
            m_iResolution = resolution;

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

            _chart.BeginUpdate();

            _chart.Title.Visible = true;
            _chart.Title.Text    = title;
            _chart.Title.Color   = lineColor;
            _chart.Title.Font    = new WpfFont("Segoe UI", 13, true, false);
            _chart.Title.Offset.SetValues(0, 20);
            _chart.ChartBackground.Color                    = ChartTools.CalcGradient(lineColor, Colors.Black, 65);
            _chart.ChartBackground.GradientDirection        = 0;
            _chart.ChartBackground.GradientFill             = GradientFill.Cylindrical;
            _chart.ViewXY.GraphBackground.GradientDirection = 270;
            _chart.ViewXY.GraphBackground.GradientFill      = GradientFill.Linear;
            _chart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.White;
            _chart.ViewXY.GraphBordersOverSeries            = false;
            _chart.ViewXY.AxisLayout.YAxesLayout            = YAxesLayout.Layered;
            _chart.ViewXY.AxisLayout.AutoAdjustMargins      = false;

            Color color = _chart.ViewXY.GraphBackground.Color;

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

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

            axisX.SetRange(0, xAxisMax);
            axisX.Title.Font     = new WpfFont("Segoe UI", 13, true, false);
            axisX.Title.Visible  = true;
            axisX.Title.Text     = "Frequency (Hz)";
            axisX.Units.Visible  = false;
            axisX.ValueType      = AxisValueType.Number;
            axisX.Position       = 100;
            axisX.LabelsPosition = Alignment.Far;
            axisX.MajorDivTickStyle.Alignment = Alignment.Far;
            axisX.MinorDivTickStyle.Alignment = Alignment.Far;
            axisX.MajorDivTickStyle.Color     = Colors.Gray;
            axisX.MinorDivTickStyle.Color     = Colors.DimGray;
            axisX.LabelsColor   = Colors.White;
            axisX.LabelsFont    = new WpfFont("Segoe UI", 11, true, false);
            axisX.ScrollMode    = XAxisScrollMode.None;
            axisX.Title.Visible = false;

            AxisY axisY = _chart.ViewXY.YAxes[0];

            axisY.MajorDivTickStyle.Color = Colors.Gray;
            axisY.MinorDivTickStyle.Color = Colors.DimGray;
            axisY.AutoFormatLabels        = false;
            axisY.LabelsNumberFormat      = "0";
            axisY.SetRange(0, 7000000);
            axisY.Title.Visible = false;
            axisY.LabelsColor   = Colors.White;
            axisY.LabelsFont    = new WpfFont("Segoe UI", 11, true, false);
            axisY.Units.Visible = false;
            axisY.Visible       = false;

            AreaSeries areaSeries = new AreaSeries(_chart.ViewXY, axisX, axisY);

            areaSeries.Title.Visible     = false;
            areaSeries.LineStyle.Color   = lineColor;
            areaSeries.LineStyle.Width   = 1f;
            areaSeries.Fill.Color        = ChartTools.CalcGradient(lineColor, Colors.Black, 50);
            areaSeries.Fill.GradientFill = GradientFill.Solid;
            areaSeries.MouseInteraction  = false;
            areaSeries.PointsVisible     = false;

            _chart.ViewXY.AreaSeries.Add(areaSeries);

            _chart.EndUpdate();

            _chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Off;

            parentControl.Children.Add(_chart);
        }
Beispiel #5
0
        /// <summary>
        /// 初始化温度曲线
        /// </summary>
        private void CreateTempChart()
        {
            //Create new _chartTemp
            _chartTemp = new LightningChartUltimate();
            _chartTemp.BeginUpdate();
            _chartTemp.ViewXY.DropOldSeriesData = true;

            _chartTemp.Parent = lightningChartUltimate1;
            _chartTemp.Name   = "出铁口铁水温度曲线";
            //_chartTemp.Title.Font.;
            _chartTemp.Title.Text  = "出铁口铁水温度曲线";
            _chartTemp.Title.Color = PublicColor.FromArgb(255, Color.Yellow);
            _chartTemp.Title.Font  = new Font("黑体", 10, FontStyle.Bold);
            //_chartTemp.Title.Visible = false;
            _chartTemp.Dock                    = DockStyle.Fill;
            _chartTemp.Background.Color        = PublicColor.FromArgb(255, Color.Gray);
            _chartTemp.Background.GradientFill = GradientFill.Solid;

            AxisX xAxis = _chartTemp.ViewXY.XAxes[0];

            xAxis.ValueType        = AxisValueType.DateTime;
            xAxis.Title.Text       = "Time";
            xAxis.AutoFormatLabels = false;

            //xAxis.LabelsTimeFormat = "dd/MM/yyyy\nHH:mm.ss";
            xAxis.LabelsTimeFormat = "HH:mm.ss";
            xAxis.LabelsAngle      = 0;
            xAxis.ScrollMode       = XAxisScrollMode.Scrolling;
            xAxis.Title.Visible    = false;
            xAxis.Visible          = false;

            //Convert DateTime values to axis values
            DateTime now  = DateTime.Now;
            double   minX = xAxis.DateTimeToAxisValue(now);
            double   maxX = xAxis.DateTimeToAxisValue(now) + 100;

            xAxis.SetRange(minX, maxX);

            //Configure y-axis
            AxisY yAxis = _chartTemp.ViewXY.YAxes[0];

            yAxis.Title.Text    = "Temperature / °C";
            yAxis.Title.Visible = false;
            yAxis.SetRange(1500, 1600);
            yAxis.LabelsFont  = new Font("黑体", 6);
            yAxis.LabelsColor = PublicColor.FromArgb(255, Color.Yellow);

            //Configure and add series to the chart
            PointLineSeries series = new PointLineSeries(_chartTemp.ViewXY, xAxis, yAxis);

            series.LineStyle.Color  = Color.Yellow;
            series.MouseInteraction = false;

            _chartTemp.ViewXY.PointLineSeries.Add(series);

            //Don't show legendbox
            _chartTemp.ViewXY.LegendBoxes[0].Visible = false;

            //Allow chart rendering
            _chartTemp.EndUpdate();
        }