Пример #1
0
        private void ToolStripComboBoxITEM_SelectedIndexChanged(object sender, EventArgs e)
        {
            // update with selected snapsots items'
            SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory;
            var xaxis = SSCat != null ? SSCat.XAxis : null;
            var yaxis = SSCat != null ? SSCat.YAxis : null;

            if (SSCat != null)
            {
                SSCat.Selected = toolStripComboBoxITEM.SelectedItem as SnapshotItem;
            }

            SnapshotItem sItem = SSCat != null?SSCat.GetSelectedItem() : null;

            if (sItem != null)
            {
                toolStripComboBoxX.ComboBox.DataSource = sItem.GetHeaderTitles();
                toolStripComboBoxX.SelectedItem        = xaxis;
                toolStripComboBoxY.ComboBox.DataSource = sItem.GetHeaderTitles();
                toolStripComboBoxY.SelectedItem        = yaxis;
            }
            else
            {
                toolStripComboBoxX.ComboBox.DataSource = null;
                toolStripComboBoxX.SelectedItem        = null;
                toolStripComboBoxY.ComboBox.DataSource = null;
                toolStripComboBoxY.SelectedItem        = null;
            }
            _getPlotData();
            chartViewer1.Redraw();
        }
Пример #2
0
        private void _getPlotData()
        {
            SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory;
            if (SSCat != null)
            {
                SnapshotItem sItem = SSCat.GetSelectedItem();

                xTitle = toolStripComboBoxX.SelectedItem as string;
                yTitle = toolStripComboBoxY.SelectedItem as string;
                dxList = sItem != null?sItem.GetDoubleArray(xTitle) : null;

                dyList = sItem != null?sItem.GetDoubleArray(yTitle) : null;

                SSCat.XAxis = xTitle;
                SSCat.YAxis = yTitle;

                double minX = double.MaxValue;
                double maxX = double.MinValue;
                double minY = double.MaxValue;
                double maxY = double.MinValue;
                if (dxList != null)
                {
                    foreach (var v in dxList)
                    {
                        if (chkNum(v))
                        {
                            minX = Math.Min(minX, v); maxX = Math.Max(maxX, v);
                        }
                    }
                }
                if (dyList != null)
                {
                    foreach (var v in dyList)
                    {
                        if (chkNum(v))
                        {
                            minY = Math.Min(minY, v); maxY = Math.Max(maxY, v);
                        }
                    }
                }
                if (minX == double.MaxValue)
                {
                    minX = 0; maxX = 1;
                }
                if (minY == double.MaxValue)
                {
                    minY = 0; maxY = 1;
                }

                if (minX == maxX)
                {
                    minX -= 1; maxX += 1;
                }
                else
                {
                    var d = (maxX - minX) / 10; minX -= d; maxX += d;
                }
                if (minY == maxY)
                {
                    minY -= 1; maxY += 1;
                }
                { var d = (maxY - minY) / 10; minY -= d; maxY += d; }

                chartViewer1.XAuto = false;
                chartViewer1.YAuto = false;


                if (SSCat.XAxisAuto)
                {
                    if (SSCat.XPolarity == Polarity.Normal)
                    {
                        chartViewer1.XLeft  = minX;
                        chartViewer1.XRight = maxX;
                    }
                    else
                    {
                        chartViewer1.XLeft  = maxX;
                        chartViewer1.XRight = minX;
                    }
                }
                else
                {
                    if (SSCat.XPolarity == Polarity.Normal)
                    {
                        chartViewer1.XLeft  = SSCat.XAxisMin;
                        chartViewer1.XRight = SSCat.XAxisMax;
                    }
                    else
                    {
                        chartViewer1.XLeft  = SSCat.XAxisMax;
                        chartViewer1.XRight = SSCat.XAxisMin;
                    }
                }
                if (SSCat.YAxisAuto)
                {
                    if (SSCat.YPolarity == Polarity.Normal)
                    {
                        chartViewer1.YTop    = maxY;
                        chartViewer1.YBottom = minY;
                    }
                    else
                    {
                        chartViewer1.YTop    = minY;
                        chartViewer1.YBottom = maxY;
                    }
                }
                else
                {
                    if (SSCat.YPolarity == Polarity.Normal)
                    {
                        chartViewer1.YTop    = SSCat.YAxisMax;
                        chartViewer1.YBottom = SSCat.YAxisMin;
                    }
                    else
                    {
                        chartViewer1.YTop    = SSCat.YAxisMin;
                        chartViewer1.YBottom = SSCat.YAxisMax;
                    }
                }

                chartViewer1.XAxisTitle = xTitle;
                chartViewer1.YAxisTitle = yTitle;

                chartViewer1.Title  = SSCat.Name + "    :    " + (sItem != null ? sItem.FormattedTime : "*");
                chartViewer1.Title2 = yTitle + " vs " + xTitle;


                SSCat.WriteSettings();
            }
        }