Beispiel #1
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) {}
            }
        }
Beispiel #2
0
        private void SetupGraph()
        {
            var series_electronegativity = new GraphControl.Series("Electronegativity");
            var series_atomic_radius     = new GraphControl.Series("Atomic Radius");
            var series_atomic_density    = new GraphControl.Series("Solid Density");

            using (var s_en = series_electronegativity.Lock())
                using (var s_ar = series_atomic_radius.Lock())
                    using (var s_ad = series_atomic_density.Lock())
                    {
                        foreach (var e in m_inst.ChemLab.KnownElements.Cast <Element>())
                        {
                            s_en.Data.Add(new GraphControl.GraphValue(e.AtomicNumber, e.Electronegativity));
                            s_ar.Data.Add(new GraphControl.GraphValue(e.AtomicNumber, e.ValenceOrbitalRadius));
                            s_ad.Data.Add(new GraphControl.GraphValue(e.AtomicNumber, e.SolidDensity));
                        }
                    }
            m_graph.Graph.Data.Add(series_electronegativity);
            m_graph.Graph.Data.Add(series_atomic_radius);
            m_graph.Graph.Data.Add(series_atomic_density);
            m_graph.Graph.FindDefaultRange();
            m_graph.Graph.ResetToDefaultRange();
        }