コード例 #1
0
ファイル: add_series.cs プロジェクト: psryland/rylogic_code
 // Construct a series from the selected blocks of data
 public Series NewSeries(DataGridView grid)
 {
     GraphControl.Series.RdrOpts ropts = new GraphControl.Series.RdrOpts();
     ropts.m_plot_type    = (GraphControl.Series.RdrOpts.PlotType)m_combo_plot_type.SelectedIndex;
     ropts.m_point_colour = ropts.m_line_colour = ropts.m_bar_colour = m_colour;
     float.TryParse(m_edit_point_size.Text, out ropts.m_point_size);
     float.TryParse(m_edit_line_size.Text, out ropts.m_line_width);
     return(new Series(grid, m_blocks[m_combo_xaxis_column.SelectedIndex], m_blocks[m_combo_yaxis_column.SelectedIndex], ropts));
 }
コード例 #2
0
        public Series(DataGridView grid, Grapher.Block xblock, Grapher.Block yblock, GraphControl.Series.RdrOpts rdr_options)
        {
            m_xblock = xblock;
            m_yblock = yblock;
            m_series = new GraphControl.Series {
                RenderOptions = rdr_options
            };

            // Choose the smallest range
            if (m_xblock.m_range.Count < m_yblock.m_range.Count)
            {
                m_yblock.m_range.Count = m_xblock.m_range.Count;
            }
            if (m_yblock.m_range.Count < m_xblock.m_range.Count)
            {
                m_xblock.m_range.Count = m_yblock.m_range.Count;
            }

            // Create the series
            double px = -double.MaxValue;

            for (int i = 0; i != m_xblock.m_range.Count; ++i)
            {
                try
                {
                    DataGridViewCell cellx   = grid[m_xblock.m_column, (int)m_xblock.m_range.Begin + i];
                    DataGridViewCell celly   = grid[m_yblock.m_column, (int)m_yblock.m_range.Begin + i];
                    object           x_boxed = Convert.ChangeType(cellx.Value, typeof(double));
                    object           y_boxed = Convert.ChangeType(celly.Value, typeof(double));
                    double           x       = x_boxed != null ? (double)x_boxed : 0.0;
                    double           y       = y_boxed != null ? (double)y_boxed : 0.0;
                    m_series.Values.Add(new GraphControl.GraphValue(x, y));
                    m_series.Sorted &= x >= px;
                    px = x;
                }
                catch (FormatException) {}
            }
        }